cooperl22 / laravel-db2

laravel-db2 is a simple DB2 service provider for Laravel. It provides DB2 Connection by extending the Illuminate Database component of the laravel framework.
Other
59 stars 65 forks source link

Paginate error with schema config #53

Open yebor974 opened 5 years ago

yebor974 commented 5 years ago

Hi,

I try to paginate my users list with:

User::paginate(5),

When i change page, i have this error:

SQLSTATE[42000]: Syntax error or access violation: 0 [IBM][Pilote ODBC System i Access][DB2 for i5/OS]SQL0104 - Texte de message d'erreur non disponible. La conversion du message ne peut pas aboutir. (SQLPrepare[0] at ext\pdo_odbc\odbc_driver.c:206) (SQL: select * from (select user.*, row_number() over (order by 1) as row_num from user) as temp_table where row_num between 6 and 10)

However, when i set my model table attribute to 'toto.user' where toto is the name of my schema/library and set config schema to the main database schema, i don't get error and all pagination is done. But i don't want to change all my $table attributes models just for this issue.

I have tried it with laravel 5.5 and laravel 5.8.

Thanks for your help,

MarkBoyer commented 5 years ago

This looks like configuration to me. Check your "Naming" parameter in the database config. The default of "0" for SQL naming will not search the server job's library list for objects. Either the "DefaultLibraries" parameter must define the library list or objects must be qualified, as you found.

yebor974 commented 5 years ago

Hi,

I tried several combinations but didn't work.

Here is some configs :

'host' => 'myIP', 'username' => 'myUser', 'password' => 'myPwd', 'database' => '', 'prefix' => '', 'schema' => 'mySchema', 'port' => 446, 'date_format' => 'Y-m-d H:i:s', 'odbc_keywords' => [ 'SIGNON' => 3, 'SSL' => 0, 'CommitMode' => 2, 'ConnectionType' => 0, 'DefaultLibraries' => 'mySchema', 'Naming' => 1, 'UNICODESQL' => 0, 'DateFormat' => 5, 'DateSeperator' => 0, 'Decimal' => 0,

All works only if i define my $table attribute of model like "mySchema.table"

Thanks for you help