Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unbreak $rs->create() with empty hashref on Oracle #61

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions lib/DBIx/Class/Storage/DBI/Oracle/Generic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ sub deployment_statements {
$self->next::method($schema, $type, $version, $dir, $sqltargs, @rest);
}

sub insert {
my ($self, $source, $to_insert) = @_;

# Oracle does not understand INSERT INTO ... DEFAULT VALUES syntax
# Furthermore it does not have any way to insert without specifying any columns
# We can't fix this in SQLMaker::Oracle because it doesn't know which column to add to the statement
unless (%$to_insert)
{
my ($col) = $source->columns;
$to_insert = { $col => \'DEFAULT' };
}

return $self->next::method($source, $to_insert);
}

sub _dbh_last_insert_id {
my ($self, $dbh, $source, @columns) = @_;
my @ids = ();
Expand Down
4 changes: 3 additions & 1 deletion t/60core.t
Original file line number Diff line number Diff line change
Expand Up @@ -570,9 +570,11 @@ lives_ok (sub { my $newlink = $newbook->link}, "stringify to false value doesn't
{
my $new_artist = $schema->resultset('Artist')->new({});
isa_ok( $new_artist, 'DBIx::Class::Row', '$rs->new gives a row object' );
lives_ok { $new_artist->insert() } 'inserting without specifying any columns works';
$new_artist->discard_changes;
$new_artist->delete;
}


# make sure we got rid of the compat shims
SKIP: {
my $remove_version = 0.083;
Expand Down
6 changes: 6 additions & 0 deletions t/73oracle.t
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,12 @@ sub _run_tests {
like ($seq, qr/\.${q}artist_pk_seq${q}$/, 'Correct PK sequence selected for sqlt-like trigger');
}

lives_ok {
$new = $schema->resultset('Artist')->create({});
$new->discard_changes;
ok $new->artistid, 'Created row has id'
} 'Create with empty hashref works';


# test LIMIT support
for (1..6) {
Expand Down