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

this makes oracle materialised views and DDL parse correctly #27

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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/DBIx/Class/Schema/Loader/Base.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2696,7 +2696,7 @@ sub _setup_src_meta {
}

my @non_nullable_uniqs = grep {
all { $col_info->{$_}{is_nullable} == 0 } @{ $_->[1] }
all { exists $col_info->{$_} && $col_info->{$_}{is_nullable} == 0 } @{ $_->[1] }
} @uniqs;

if ($self->uniq_to_primary && (not @$pks) && @non_nullable_uniqs) {
Expand Down
5 changes: 5 additions & 0 deletions lib/DBIx/Class/Schema/Loader/DBI/Oracle.pm
Original file line number Diff line number Diff line change
Expand Up @@ -113,14 +113,19 @@ EOF
sub _table_uniq_info {
my ($self, $table) = @_;

## Oracle's DDL for materialised views makes it really easy to conflate
## with tables. Adding the left join here means don't pick up
## spurious virtual column constraints for mvs
my $sth = $self->dbh->prepare_cached(<<'EOF', {}, 1);
SELECT ac.constraint_name, acc.column_name
FROM all_constraints ac, all_cons_columns acc
LEFT JOIN all_mviews mv on mv.owner = acc.owner and mv.mview_name = acc.table_name
WHERE acc.table_name=? AND acc.owner = ?
AND ac.table_name = acc.table_name AND ac.owner = acc.owner
AND acc.constraint_name = ac.constraint_name
AND ac.constraint_type = 'U'
AND ac.status = 'ENABLED'
AND mv.mview_name is null
ORDER BY acc.position
EOF

Expand Down