-
-
Notifications
You must be signed in to change notification settings - Fork 74
code: 101, message: Unexpected packet Query received from client when updating many-to-many association #147
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
Comments
Further research indicates to me that Clickhouse does not even support constraints with foreign keys. It does not seem to be supported in their SQL spec. See: Take for instance this table: type User struct {
HModel
Email string `gorm:"index"`
Roles []*Role `gorm:"many2many:user_roles;"`
FirstName string
LastName string
Role string
}
...
type HModel struct {
ID string `gorm:"primarykey"`
CreatedAt time.Time
UpdatedAt time.Time
// DeletedAt DeletedAt `gorm:"index"`
} When doing a ALTER TABLE `user_roles` ADD CONSTRAINT `fk_user_roles_role`
FOREIGN KEY (`role_id`,`role_type`) REFERENCES `roles`(`id`,`type`) But, at least based on my very limited (a week worth of messing with Clickhouse) this SQL statement is just wrong. For instance running it in clickhouse-client results in:
Maybe someone could shed light on this. But - as far as i can tell - this driver is just basically broken. |
I think the only reasonable way to do many-to-many in clickhouse would be to simply use the Anyone? thoughts? Or please tell me I am missing something big here. |
I'm running into this as well, @edhemphill did you figure this out at all, maybe there's a way to disable foreign keys? |
I disabled foreign keys, like so:
|
Not sure this is a bug or my own misunderstanding of gorm:
These models:
an implementation of adding an alias for a visitor like this:
Fails like such:
However, an implementation calling my own SQL works fine:
Results:
Verified everything using the clickhouse client.
My understanding is that the error:
code: 101, message: Unexpected packet Query received from client
Is likely when the same client is asked to start a new transaction while waiting on another to complete. My cursory glance at the source confirms this.
Notice that the clickhouse-go
end of stream
event never occurs in the first implementation. Is the gorm clickhouse driver not waiting for the first action to complete, or am i doing something wrong here?related:
ClickHouse/clickhouse-go#322
ClickHouse/clickhouse-go#485
The text was updated successfully, but these errors were encountered: