FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
sqlc-gen-python/internal/postgresql_type.go at main · sqlc-dev/sqlc-gen-python · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
sqlc-dev
/
sqlc-gen-python
Public
Notifications
You must be signed in to change notification settings
Fork
50
Star
337
Code
Issues
36
Pull requests
17
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
sqlc-gen-python
/
internal
/
postgresql_type.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (58 loc) · 2.03 KB
Breadcrumbs
sqlc-gen-python
/
internal
/
postgresql_type.go
Copy path
File metadata and controls
62 lines (58 loc) · 2.03 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package
python
import
(
"log"
"github.com/sqlc-dev/plugin-sdk-go/plugin"
"github.com/sqlc-dev/plugin-sdk-go/sdk"
)
func
postgresType
(
req
*
plugin.
GenerateRequest
,
col
*
plugin.
Column
)
string
{
columnType
:=
sdk
.
DataType
(
col
.
Type
)
switch
columnType
{
case
"serial"
,
"serial4"
,
"pg_catalog.serial4"
,
"bigserial"
,
"serial8"
,
"pg_catalog.serial8"
,
"smallserial"
,
"serial2"
,
"pg_catalog.serial2"
,
"integer"
,
"int"
,
"int4"
,
"pg_catalog.int4"
,
"bigint"
,
"int8"
,
"pg_catalog.int8"
,
"smallint"
,
"int2"
,
"pg_catalog.int2"
:
return
"int"
case
"float"
,
"double precision"
,
"float8"
,
"pg_catalog.float8"
,
"real"
,
"float4"
,
"pg_catalog.float4"
:
return
"float"
case
"numeric"
,
"pg_catalog.numeric"
,
"money"
:
return
"decimal.Decimal"
case
"boolean"
,
"bool"
,
"pg_catalog.bool"
:
return
"bool"
case
"json"
,
"jsonb"
:
return
"Any"
case
"bytea"
,
"blob"
,
"pg_catalog.bytea"
:
return
"memoryview"
case
"date"
:
return
"datetime.date"
case
"pg_catalog.time"
,
"pg_catalog.timetz"
:
return
"datetime.time"
case
"pg_catalog.timestamp"
,
"pg_catalog.timestamptz"
,
"timestamptz"
:
return
"datetime.datetime"
case
"interval"
,
"pg_catalog.interval"
:
return
"datetime.timedelta"
case
"text"
,
"pg_catalog.varchar"
,
"pg_catalog.bpchar"
,
"string"
,
"citext"
:
return
"str"
case
"uuid"
:
return
"uuid.UUID"
case
"inet"
,
"cidr"
,
"macaddr"
,
"macaddr8"
:
// psycopg2 does have support for ipaddress objects, but it is not enabled by default
//
// https://www.psycopg.org/docs/extras.html#adapt-network
return
"str"
case
"ltree"
,
"lquery"
,
"ltxtquery"
:
return
"str"
default
:
for
_
,
schema
:=
range
req
.
Catalog
.
Schemas
{
if
schema
.
Name
==
"pg_catalog"
||
schema
.
Name
==
"information_schema"
{
continue
}
for
_
,
enum
:=
range
schema
.
Enums
{
if
columnType
==
enum
.
Name
{
if
schema
.
Name
==
req
.
Catalog
.
DefaultSchema
{
return
"models."
+
modelName
(
enum
.
Name
,
req
.
Settings
)
}
return
"models."
+
modelName
(
schema
.
Name
+
"_"
+
enum
.
Name
,
req
.
Settings
)
}
}
}
log
.
Printf
(
"unknown PostgreSQL type: %s
\n
"
,
columnType
)
return
"Any"
}
}
Back
|
FazBrowse Home
|
New Git URL