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

gorm dialect plugin #10

Open
ghost opened this issue Feb 16, 2020 · 8 comments
Open

gorm dialect plugin #10

ghost opened this issue Feb 16, 2020 · 8 comments

Comments

@ghost
Copy link

ghost commented Feb 16, 2020

Hi,

Hope you are all well !

Would be awesome and popular to create a dialect plugin for gorm.io

refs.
https://github.com/jinzhu/gorm/tree/master/dialects

How complicated it would be ? Is it doable ?

Cheers,
X

@tomatolog
Copy link

PR are welcome

@ghost
Copy link
Author

ghost commented Feb 16, 2020

Could the mysql dialect be enough and compatible ?

@tomatolog
Copy link

tomatolog commented Feb 16, 2020

someone with gorm knowledge might answer that question - we have no developers with knowledge of gorm.io that is why it is hard to tell MySQL gorm dialect could work with Manticore or not

@ghost
Copy link

ghost commented Feb 16, 2020

I posted an issue about that as I am interested too, https://github.com/jinzhu/gorm/issues/2887

@manticoresearch
Copy link
Contributor

@x0rzkov @lucmichalski
Here https://github.com/jinzhu/gorm/blob/master/dialects/mysql/mysql.go I see that gorm uses https://github.com/go-sql-driver/mysql which has Sphinx as a requirement:

MySQL (4.1+), MariaDB, Percona Server, Google CloudSQL or Sphinx (2.2.3+)

and in their Sphinx repo they say to use the mysql driver instead - https://github.com/go-sql-driver/sphinxql

So I guess that in general gorm should support Manticore too. We'll appreciate if you give it a try and if you have any issue we'll be glad to help you solve it.

@adriannuta
Copy link

You need to set interpolateParams=True in mysql DSN because Manticore doesn't support prepared statements, so they need to be emulated on client-side.

Also the default gorm model has some columns like deletedAt - unless you have these in the index, don't inherit the default model.

The only issue I see so far is with First() method (and possible others) that orders automatically by primary key (and id is forced as primary key, I don't see a way to forbid that) as it creates a table.column syntax in ORDER BY, which we currently don't support. I tested Where() and Create() and they seem to be fine.

@ghost
Copy link

ghost commented Feb 24, 2020

Hi,

I am creating a wordpress clone with qor/gin and I have the following sql query.

(/Users/lucmichalski/go/src/github.com/koreset/homefapp/services/post.go:17) 
[2020-02-24 06:24:57]  [1508.04ms]  SELECT * FROM `posts`  WHERE (type in ('article','press_release','news') and body != '') ORDER BY created desc LIMIT 3 OFFSET 0  
[0 rows affected or returned ] 

(/Users/lucmichalski/go/src/github.com/koreset/homefapp/services/post.go:17) 
[2020-02-24 06:24:58]  [94.79ms]  SELECT * FROM `categories` INNER JOIN `category_post` ON `category_post`.`category_id` = `categories`.`id` WHERE (1 <> 1)  
[0 rows affected or returned ] 

(/Users/lucmichalski/go/src/github.com/koreset/homefapp/services/post.go:17) 
[2020-02-24 06:24:58]  [15.00ms]  SELECT * FROM `tags` INNER JOIN `tag_post` ON `tag_post`.`tag_id` = `tags`.`id` WHERE (1 <> 1)  
[0 rows affected or returned ] 

(/Users/lucmichalski/go/src/github.com/koreset/homefapp/services/post.go:17) 
[2020-02-24 06:24:58]  [36.11ms]  SELECT * FROM `posts`  WHERE (type in ('article','press_release','news') and body != '') ORDER BY created desc LIMIT 3 OFFSET 4  
[0 rows affected or returned ] 

(/Users/lucmichalski/go/src/github.com/koreset/homefapp/services/post.go:17) 
[2020-02-24 06:24:58]  [6.66ms]  SELECT * FROM `categories` INNER JOIN `category_post` ON `category_post`.`category_id` = `categories`.`id` WHERE (1 <> 1)  
[0 rows affected or returned ] 

(/Users/lucmichalski/go/src/github.com/koreset/homefapp/services/post.go:17) 
[2020-02-24 06:24:58]  [3.14ms]  SELECT * FROM `tags` INNER JOIN `tag_post` ON `tag_post`.`tag_id` = `tags`.`id` WHERE (1 <> 1)  
[0 rows affected or returned ] 

(/Users/lucmichalski/go/src/github.com/koreset/homefapp/services/post.go:50) 
[2020-02-24 06:24:58]  [3.78ms]  SELECT * FROM `posts`  WHERE (type = 'video') ORDER BY created desc  
[0 rows affected or returned ] 

Are they compatible with manticore ?

@adriannuta
Copy link

Joining is not possible currently in Manticore.

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

4 participants