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

Problem with DBIx-Custom and MariaDB #13

Open
sseide opened this issue Nov 23, 2017 · 4 comments
Open

Problem with DBIx-Custom and MariaDB #13

sseide opened this issue Nov 23, 2017 · 4 comments

Comments

@sseide
Copy link

sseide commented Nov 23, 2017

Hello,

i have an program using your DBIx-Custom library and DBIx::Custom::NotExists whenever i do not have values for an row. This is working fine with mysql 5.5 as backend database but does not work with mariadb 10.1 (the new replacement for mysql on most linux distros)

A sample code is:

my $where = $dbi->where();
my $param = { 
	startDate => $start_date // $dbi->not_exists,
    	endDate => $end_date // $dbi->not_exists
};
$where->clause( ['and', 'shows.start_time >= :startDate', 'shows.start_time <= :endDate');
$where->param( $param );
my $result = $dbi->select( table => 'shows', where => $where);

The resulting sql statements (checked in the server logfiles) whenever endDate is not set will be
for MySQL 5.5:

select * from shows where show.start_time >= '2017-11-11'

The same for MariaDB 10.1:

select * from shows where shows.start_time >= '2017-11-11' and shows.endTime <= 'DBIx::Custom::NotExists=HASH(0x55fd2d068b98)'

As you can see with MariaDB the where clause is not omitted and the string of your object is bound as parameter.

It is reproducible every time - i just start the program an either point to an mysql server or an mariadb-server and the results change as mentioned above...

Do you have an ideas where this different behavior comes from?

Debian 9.1
Perl 5.25
libdbi-perl 1.636-1
libdbd-mysql-perl 4.041-2
DBIx::Custom 0.41
DBIx::Connector 0.56

Thanks,
Stefan Seide

@yuki-kimoto
Copy link
Owner

yuki-kimoto commented Nov 23, 2017 via email

@sseide
Copy link
Author

sseide commented Nov 23, 2017

Many thanks, change the code to your second example, that is working again.

But none the less found my way shorter and easier to read :) And it worked well with MySQL. Don't now what the difference is with MariaDB...

Shall it be closed or left open as a reminder to check for differences with MySQL / MariaDB?

@sseide
Copy link
Author

sseide commented Nov 23, 2017

The following fix seems to get it working again for me - now the NotExists works on booth MySQL and MariaDB without an Array reference.

unified Diff of Where.pm (Version 0.41)

--- Where.pm	2017-11-23 15:29:23.754074744 +0100
+++ Where-fix.pm	2017-11-23 15:29:12.742077560 +0100
@@ -117,7 +117,9 @@
           $pushed = 1 if exists $param->{$column}->[$count - 1]
             && ref $param->{$column}->[$count - 1] ne 'DBIx::Custom::NotExists'
         }
-        elsif ($count == 1) { $pushed = 1 }
+        elsif ($count == 1) {
+          $pushed = 1 if ref $param->{$column} ne 'DBIx::Custom::NotExists'
+        }
       }
       push @$where, $clause if $pushed;
     }

@yuki-kimoto
Copy link
Owner

yuki-kimoto commented Nov 27, 2017 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants