laravel-cross-eloquent-search icon indicating copy to clipboard operation
laravel-cross-eloquent-search copied to clipboard

Support SQLite3

Open MeiKatz opened this issue 4 years ago • 4 comments

Hej,

are there any plans to support SQLite3 as database driver? I am developing my apps with SQLite3 on my machine and with MySQL on the production server. So far I cannot use this package as much as I would like to. And I don't think that I would be this hard:

  • use LENGTH() instead of CHAR_LENGTH()
  • escape column names because SQLite3 does not support a number as the first character of a column name

If you would like I could create a pull request. I only need one hint: where are the columns like 0_post_key are defined? Couldn't find it for now.

MeiKatz avatar Oct 31 '21 19:10 MeiKatz

Okay, I tried successfully to adjust it for SQLite3 and it was quite easy:

  • ~I prefixed the column names with a single character: 0_post_key got a0_post_key~
  • => get the grammar and wrap the column name ($builder->getGrammar()->wrap( $column ))
  • I added a single NULL in the COALESCE() function because SQLite3 expects at least two arguments
  • use LENGTH() instead of CHAR_LENGTH()

... and that is nearly all. I discovered an issue for modules that don't have timestamp column (EDIT: created an issue for this #39). Will further invest into this tomorrow.

MeiKatz avatar Oct 31 '21 19:10 MeiKatz