[Jifty-commit] r6344 - in Jifty-DBI/trunk: . lib/Jifty/DBI
Jifty commits
jifty-commit at lists.jifty.org
Tue Feb 17 18:18:41 EST 2009
Author: alexmv
Date: Tue Feb 17 18:18:40 2009
New Revision: 6344
Modified:
Jifty-DBI/trunk/ (props changed)
Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
Jifty-DBI/trunk/t/06filter_boolean.t
Log:
r42154 at kohr-ah: chmrr | 2009-02-17 18:18:04 -0500
* apply filters to "default is ..." values, so "is boolean, default is 0" works on pg, for instance
Modified: Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm
==============================================================================
--- Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm (original)
+++ Jifty-DBI/trunk/lib/Jifty/DBI/SchemaGenerator.pm Tue Feb 17 18:18:40 2009
@@ -277,12 +277,25 @@
next if (!$model->can('schema_version') or !defined $model->schema_version)
and defined $column->till;
+ # Encode default values
+ my $default = $column->default;
+ if (defined $default) {
+ $model->_handle($self->handle);
+ $model->_apply_input_filters(
+ column => $column,
+ value_ref => \$default,
+ );
+ $model->_handle(undef);
+ } else {
+ $default = '';
+ }
+
push @cols,
DBIx::DBSchema::Column->new(
{ name => $column->name,
type => $column->type,
null => $column->mandatory ? 0 : 1,
- default => $column->default ||'',
+ default => $default,
}
);
Modified: Jifty-DBI/trunk/t/06filter_boolean.t
==============================================================================
--- Jifty-DBI/trunk/t/06filter_boolean.t (original)
+++ Jifty-DBI/trunk/t/06filter_boolean.t Tue Feb 17 18:18:40 2009
@@ -6,7 +6,7 @@
BEGIN { require "t/utils.pl" }
our (@available_drivers);
-use constant TESTS_PER_DRIVER => 136;
+use constant TESTS_PER_DRIVER => 139;
my $total = scalar(@available_drivers) * TESTS_PER_DRIVER;
plan tests => $total;
@@ -105,6 +105,9 @@
ok($rec->load($id), 'loaded record');
is($rec->id, $id, 'record id matches');
is($rec->other_data, 0, 'default mandatory column is false, not undef');
+ is($rec->def_t, 1, 'default is correct if given as "t"');
+ is($rec->def_one, 1, 'default is correct if given as 1');
+ is($rec->def_zero, 0, 'default is correct if given as 0');
$rec->set_other_data(1);
is($rec->other_data, 1, 'mandatory column is now true');
@@ -126,7 +129,10 @@
CREATE table users (
id integer primary key,
my_data boolean,
- other_data boolean not null
+ other_data boolean not null,
+ def_t boolean default true,
+ def_one boolean default true,
+ def_zero boolean default true
)
EOF
@@ -138,7 +144,10 @@
CREATE TEMPORARY table users (
id integer auto_increment primary key,
my_data boolean,
- other_data boolean not null
+ other_data boolean not null,
+ def_t boolean default true,
+ def_one boolean default true,
+ def_zero boolean default false
)
EOF
@@ -150,7 +159,10 @@
CREATE TEMPORARY table users (
id serial primary key,
my_data boolean,
- other_data boolean not null
+ other_data boolean not null,
+ def_t boolean default true,
+ def_one boolean default true,
+ def_zero boolean default false
)
EOF
@@ -166,6 +178,18 @@
column other_data =>
is boolean,
is mandatory;
+
+ column def_t =>
+ is boolean,
+ default is 't';
+
+ column def_one =>
+ is boolean,
+ default is 1;
+
+ column def_zero =>
+ is boolean,
+ default is 0;
}
}
More information about the Jifty-commit
mailing list