sqlc-dev / sqlc

Generate type-safe code from SQL
https://sqlc.dev
MIT License
13.37k stars 803 forks source link

Update will be needed for undefined type: ast.PatternLikeExpr #2169

Closed ericbock closed 1 year ago

ericbock commented 1 year ago

Version

1.17.2

What happened?

It looks like an update to pingcap/tidb, https://github.com/pingcap/tidb/issues/40943, removed the ast.PatternLikeExpr type in favor of ast.PatternLikeOrIlikeExpr. internal/engine/dolphin/convert.go will need to be updated if this dependency is updated.

Relevant log output

../../go/pkg/mod/github.com/kyleconroy/sqlc@v1.17.2/internal/engine/dolphin/convert.go:1066:46: undefined: ast.PatternLikeExpr
../../go/pkg/mod/github.com/kyleconroy/sqlc@v1.17.2/internal/engine/dolphin/convert.go:1623:14: undefined: ast.PatternLikeExpr

Database schema

No response

SQL queries

No response

Configuration

No response

Playground URL

No response

What operating system are you using?

macOS

What database engines are you using?

PostgreSQL

What type of code are you generating?

Go

panthershark commented 1 year ago

This bug still appears to be in 1.18.0. I'm using linux. I'm trying to figure out why it started happening to me today b/c there was no change to the sql code that is being parsed.

panthershark commented 1 year ago

I think I figured out what happened to me. I used go get -u ./... to update all dependencies. This also updated the indirect dependencies, where tidb was in that list. So tidb was set to a version that is not compatible with sqlc.

I found that the version of tidb that was listed as an indirect dependency in go.mod did not match what was specified in sqlc's go.mod file.

This fixed it for me:

  1. uninstall sqlc and tidb
  2. reinstall sqlc
  3. tidy & vendor

    
    go get github.com/kyleconroy/sqlc@none
    go get github.com/pingcap/tidb/parser@none

go get github.com/kyleconroy/sqlc@v1.18.0 go mod tidy && go mod vendor



----  

tldr: This does not appear to be a bug with `sqlc` but a side effect of blindly upgrading all dependencies.   

This issue should be closed. 
ericbock commented 1 year ago

That's how I ran into this, with go get -u ./.... sqlc is currently fine with the tidb version it's using (at least it was when I opened this.) I tried to frame this issue as, "if you update tidb, you'll need to make changes", but if this just clutters the backlog it would make sense to close this issue.

kyleconroy commented 1 year ago

Going to close this, but it is something we'll have to fix once we upgrade tidb, which will happen sometime this month.