Subject: | Fey::SQL::Insert->values method mixing up order ? |
Hello,
I'm using something similar to the following code to explicitely add
columns to an insert statement, as some of the columns uses database
functions as default value. (The actual code is a little bit more
complex, but the values are verified by printf debugging):
--- snip ---
my $child_data = {
'parent' => '4',
'child_count' => 2,
'child_index' => 2,
'child' => '3'
};
my @relation_keys = qw(child_count child_index child parent);
my $relations_table = $schema->table($self->relation_table);
my $sql = Fey::SQL->new_insert();
$sql->insert->into(map {$relations_table->column($_)} @relation_keys);
$sql->values(%$child_data);
my @bind = $sql->bind_params;
print Dumper $sql->sql($db);
print Dumper $child_data;
print Dumper \@bind;
--- snip ---
Which outputs this
$VAR1 = 'INSERT INTO "node_relations" ("child_count", "child_index",
"child", "parent") VALUES (?, ?, ?, ?)';
$VAR1 = {
'parent' => '4',
'child_count' => 2,
'child_index' => 1,
'child' => '2'
};
$VAR1 = [ '4', 2, 1, '2' ];
Neglecting Integer/String type issues in my code I was expecting Fey to
return the bind_params as given by the order of the columns used with
the into method. Is this expectation flawed and should I use another
mechanism for inserting a subset of columns ?
Thanks,
Martin