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

UUID support dbic , fixes issue #145 #146

Open
wants to merge 3 commits 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
8 changes: 8 additions & 0 deletions lib/Yancy/Backend/Dbic.pm
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,11 @@ sub read_schema {
my $default = ref $c->{default_value} eq 'SCALAR'
? ${ $c->{default_value} }
: $c->{default_value };

if ( $default && $default =~ m#[\w]+\s*\(.*\)# && ! exists $fix_default{$default} ) {
$default = undef;
}

$schema{ $schema_name }{ properties }{ $column } = {
$self->_map_type( $c ),
$is_auto ? ( readOnly => true ) : (),
Expand Down Expand Up @@ -394,6 +399,9 @@ sub _map_type {
elsif ( $db_type =~ /(?:blob|bytea)/i ) {
%conf = ( %conf, type => 'string', format => 'binary' );
}
elsif ( $db_type =~ /(?:uuid)/i ) {
%conf = ( %conf, type => 'string', format => 'uuid' );
}
else {
# Default to string
%conf = ( %conf, type => 'string' );
Expand Down
6 changes: 5 additions & 1 deletion lib/Yancy/Controller/Yancy.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,12 @@ sub _get_list_args {
for my $key ( @{ $c->req->params->names } ) {
next unless exists $props->{ $key };
my $type = $props->{$key}{type} || 'string';
my $format = $props->{$key}{format} // '' ;
my $value = $c->param( $key );
if ( is_type( $type, 'string' ) ) {
if ( is_type( $type, 'string' ) && $format eq 'uuid' ) {
$param_filter{ $key } = $value ;
}
elsif ( is_type( $type, 'string' ) ) {
if ( ( $value =~ tr/*/%/ ) <= 0 ) {
$value = "\%$value\%";
}
Expand Down