go-gorm / postgres

GORM PostgreSQL driver
MIT License
225 stars 119 forks source link

ERROR: syntax error at or near "s" (SQLSTATE 42601) #236

Closed iTanken closed 6 months ago

iTanken commented 8 months ago

When table or field comments contain ' single quotes, using logger.ExplainSQL may lead to syntax errors due to the single quotes being escaped using MySQL's syntax \' in the SQL statements.

SQLSTATE 42601

COMMENT ON COLUMN "users"."name" IS 'user\'s name'
ERROR: syntax error at or near "s" (SQLSTATE 42601)

https://github.com/go-gorm/postgres/blob/68a877c11af52552b7eb5e061a66240a0f6508cb/migrator.go#L167-L174 https://github.com/go-gorm/postgres/blob/68a877c11af52552b7eb5e061a66240a0f6508cb/migrator.go#L216-L223 https://github.com/go-gorm/postgres/blob/68a877c11af52552b7eb5e061a66240a0f6508cb/migrator.go#L270-L277

iTanken commented 8 months ago

@jinzhu Can a new version of gorm be released to update it to the latest version and fix this issue?

iTanken commented 6 months ago

Fixed #236 in tag v1.5.6 by ae7e527.