go-gorm / sharding

High performance table sharding plugin for Gorm.
MIT License
255 stars 48 forks source link

does gorm sharding support JOIN ? #126

Open nankingrider opened 11 months ago

nankingrider commented 11 months ago

Your Question

in project when i use gorm sharding and my SQL contains JOIN, like A.col1, B.col2 the query will fail. the query trys to find the main table instead of sub table

The document you expected this should be explained

Expected answer

any help ? thanks

nankingrider commented 11 months ago
image

use a.col in sql in select section not from section , found that table name not replaces by sub table name

nankingrider commented 11 months ago
image

in join sql , here stmt.fromItems's type is func (JoinClause) source(), not func (TableName) source()

so currently , no join sql can be processed correctly

jiekun commented 9 months ago

We've done it couple years ago. check it here: https://github.com/go-gorm/sharding/pull/15 This repo aims to support both PG and MySQL. So it cannot be merged.

steve-hb commented 8 months ago

I just looked at the before mentioned PR and started looking for alternatives to sqlparser, but I can't find one actively maintained. Also I just looked into gorm and found gorm to build everything itself. Do I miss/not find something?

jiekun commented 8 months ago

I just looked at the before mentioned PR and started looking for alternatives to sqlparser, but I can't find one actively maintained. Also I just looked into gorm and found gorm to build everything itself. Do I miss/not find something?

Just try https://github.com/pingcap/parser . BTW I think a SQL parser doesn't need to be updated frequently. It should just remain as stable as possible.