Re: column_info()'s COLUMN_DEF values - literal vs function

"H.Merijn Brand" <[email protected]>
Newsgroups gmane.comp.lang.perl.modules.dbi.sybase.devel
Message-ID <[email protected]>
On Wed, 27 May 2009 15:40:13 +0100, Tim Bunce <[email protected]>
wrote:

> How does your DBI driver represent a default column value in the results
> returned by the column_info() method?
> 
> Specifically, does it distinguish between default literal strings and
> default functions/expressions?
> 
> Consider the difference between these two column definitions
> 
>     bar1 timestamp not null default 'current_timestamp',
>     bar2 timestamp not null default  current_timestamp,
> 
> or, more generally:
> 
>     foo1 varchar(20) not null default 'current_user',
>     foo2 varchar(20) not null default  current_user,
> 
> This issue has cropped up in relation to a bug Jos has filed against
> DBIx::Class::Schema::Loader: https://rt.cpan.org/Ticket/Display.html?id=46412
> 
> The ODBC 3.0 spec says
> http://web.archive.org/web/20070513203826/http://msdn.microsoft.com/library/en-us/odbc/htm/odbcsqlcolumns.asp
> 
>     The default value of the column. The value in this column should be
>     interpreted as a string *if it is enclosed in quotation marks*.
> 
>     If NULL was specified as the default value, then this column is the word
>     NULL, not enclosed in quotation marks. If the default value cannot be
>     represented without truncation, then this column contains TRUNCATED,
>     with no enclosing single quotation marks. If no default value was
>     specified, then this column is NULL.
> 
>     *The value of COLUMN_DEF can be used in generating a new column
>     definition*, except when it contains the value TRUNCATED.
> 
> (The *emphasis* is mine.)
> 
> So, people, what does your database driver do for these cases?
> Are COLUMN_DEF values for literal defaults returned by column_info()
> enclosed in quotation marks?

Unify, and thus DBD::Unify, does not have support for default values
in CREATE TABLE statements at all, so just tell me what to do. Ignore
or fill with NULL

DBD::CSV is completely depending on SQL::Statement through DBD::File
here, and as DBD::CSV has no concept (yet) of a stored DDD, there is no
real use for it al all.

-- 
H.Merijn Brand  http://tux.nl      Perl Monger  http://amsterdam.pm.org/
using & porting perl 5.6.2, 5.8.x, 5.10.x, 5.11.x on HP-UX 10.20, 11.00,
11.11, 11.23, and 11.31, OpenSuSE 10.3, 11.0, and 11.1, AIX 5.2 and 5.3.
http://mirrors.develooper.com/hpux/           http://www.test-smoke.org/
http://qa.perl.org      http://www.goldmark.org/jeff/stupid-disclaimers/
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.