@@ -2,38 +2,35 @@ package python
2
2
3
3
import (
4
4
"log"
5
+ "strings"
5
6
6
7
"github.com/sqlc-dev/plugin-sdk-go/plugin"
7
8
"github.com/sqlc-dev/plugin-sdk-go/sdk"
8
9
)
9
10
10
11
func sqliteType (req * plugin.GenerateRequest , col * plugin.Column ) string {
11
- columnType := sdk .DataType (col .Type )
12
+ columnType := strings . ToLower ( sdk .DataType (col .Type ) )
12
13
13
14
switch columnType {
14
- case "INTEGER " , "INT " , "TINYINT " , "SMALLINT " , "MEDIUMINT " , "BIGINT " , "INT2 " , "INT8 " :
15
+ case "int " , "integer " , "tinyint " , "smallint " , "mediumint " , "bigint " , "unsigned big int " , "int2" , "int8 " :
15
16
return "int"
16
- case "REAL " , "DOUBLE " , "DOUBLE PRECISION " , "FLOAT " :
17
+ case "real " , "double " , "double precision " , "float " :
17
18
return "float"
18
- case "NUMERIC " , "DECIMAL " :
19
+ case "numeric " , "decimal " :
19
20
return "decimal.Decimal"
20
- case "BOOLEAN " :
21
+ case "boolean " :
21
22
return "bool"
22
- case "JSON " :
23
+ case "json " :
23
24
return "Any"
24
- case "BLOB " :
25
+ case "blob " :
25
26
return "memoryview"
26
- case "DATE " :
27
+ case "date " :
27
28
return "datetime.date"
28
- case "TIME" :
29
- return "datetime.time"
30
- case "DATETIME" , "TIMESTAMP" :
29
+ case "datetime" :
31
30
return "datetime.datetime"
32
- case "TEXT " , "CHARACTER " , "VARCHAR " , "NCHAR " , "NVARCHAR " , "CLOB " :
31
+ case "text " , "character " , "varchar " , "nchar " , "nvarchar " , "clob " :
33
32
return "str"
34
33
default :
35
- // SQLite doesn't have built-in UUID, INET, CIDR, MACADDR, or INTERVAL types
36
- // It also doesn't have an ENUM type, but we'll keep the enum check for consistency
37
34
for _ , schema := range req .Catalog .Schemas {
38
35
for _ , enum := range schema .Enums {
39
36
if columnType == enum .Name {
0 commit comments