@@ -10,7 +10,6 @@ import (
1010
1111 "github.com/kyleconroy/sqlc/internal/codegen/sdk"
1212 "github.com/kyleconroy/sqlc/internal/inflection"
13- "github.com/kyleconroy/sqlc/internal/info"
1413 "github.com/kyleconroy/sqlc/internal/metadata"
1514 "github.com/kyleconroy/sqlc/internal/plugin"
1615 pyast "github.com/kyleconroy/sqlc/internal/python/ast"
@@ -482,7 +481,7 @@ func buildQueries(req *plugin.CodeGenRequest, structs []Struct) ([]Query, error)
482481 return qs , nil
483482}
484483
485- func moduleNode (source string ) * pyast.Module {
484+ func moduleNode (version , source string ) * pyast.Module {
486485 mod := & pyast.Module {
487486 Body : []* pyast.Node {
488487 poet .Comment (
@@ -492,7 +491,7 @@ func moduleNode(source string) *pyast.Module {
492491 "versions:" ,
493492 ),
494493 poet .Comment (
495- " sqlc " + info . Version ,
494+ " sqlc " + version ,
496495 ),
497496 },
498497 }
@@ -661,7 +660,7 @@ func buildImportGroup(specs map[string]importSpec) *pyast.Node {
661660}
662661
663662func buildModelsTree (ctx * pyTmplCtx , i * importer ) * pyast.Node {
664- mod := moduleNode ("" )
663+ mod := moduleNode (ctx . SqlcVersion , "" )
665664 std , pkg := i .modelImportSpecs ()
666665 mod .Body = append (mod .Body , buildImportGroup (std ), buildImportGroup (pkg ))
667666
@@ -793,7 +792,7 @@ func asyncQuerierClassDef() *pyast.ClassDef {
793792}
794793
795794func buildQueryTree (ctx * pyTmplCtx , i * importer , source string ) * pyast.Node {
796- mod := moduleNode (source )
795+ mod := moduleNode (ctx . SqlcVersion , source )
797796 std , pkg := i .queryImportSpecs (source )
798797 mod .Body = append (mod .Body , buildImportGroup (std ), buildImportGroup (pkg ))
799798 mod .Body = append (mod .Body , & pyast.Node {
@@ -1028,12 +1027,13 @@ func buildQueryTree(ctx *pyTmplCtx, i *importer, source string) *pyast.Node {
10281027}
10291028
10301029type pyTmplCtx struct {
1031- Models []Struct
1032- Queries []Query
1033- Enums []Enum
1034- EmitSync bool
1035- EmitAsync bool
1036- SourceName string
1030+ Models []Struct
1031+ Queries []Query
1032+ Enums []Enum
1033+ EmitSync bool
1034+ EmitAsync bool
1035+ SourceName string
1036+ SqlcVersion string
10371037}
10381038
10391039func (t * pyTmplCtx ) OutputQuery (sourceName string ) bool {
@@ -1060,11 +1060,12 @@ func Generate(req *plugin.CodeGenRequest) (*plugin.CodeGenResponse, error) {
10601060 }
10611061
10621062 tctx := pyTmplCtx {
1063- Models : models ,
1064- Queries : queries ,
1065- Enums : enums ,
1066- EmitSync : req .Settings .Python .EmitSyncQuerier ,
1067- EmitAsync : req .Settings .Python .EmitAsyncQuerier ,
1063+ Models : models ,
1064+ Queries : queries ,
1065+ Enums : enums ,
1066+ EmitSync : req .Settings .Python .EmitSyncQuerier ,
1067+ EmitAsync : req .Settings .Python .EmitAsyncQuerier ,
1068+ SqlcVersion : req .SqlcVersion ,
10681069 }
10691070
10701071 output := map [string ]string {}
0 commit comments