-
Notifications
You must be signed in to change notification settings - Fork 33
fix: types reflection #33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f4b82cf
d2534e0
9fbbc68
fa8a9ca
b376932
1ea934e
fd774c9
c876f03
456cd11
6f0c8c7
d7e08df
a10e3f2
b836cff
e108187
7d1a34e
c4b8b33
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ | |
| "DATETIME": types.DATETIME, | ||
| "FLOAT64": types.Float, | ||
| "INT64": types.BIGINT, | ||
| "NUMERIC": types.DECIMAL, | ||
| "NUMERIC": types.NUMERIC(precision=38, scale=9), | ||
| "STRING": types.String, | ||
| "TIME": types.TIME, | ||
| "TIMESTAMP": types.TIMESTAMP, | ||
|
|
@@ -176,6 +176,9 @@ def visit_BINARY(self, type_, **kw): | |
| def visit_DECIMAL(self, type_, **kw): | ||
| return "NUMERIC" | ||
|
|
||
| def visit_NUMERIC(self, type_, **kw): | ||
| return "NUMERIC" | ||
IlyaFaer marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| def visit_VARCHAR(self, type_, **kw): | ||
| return "STRING({})".format(type_.length) | ||
|
|
||
|
|
@@ -314,12 +317,17 @@ def get_columns(self, connection, table_name, schema=None, **kw): | |
| columns = snap.execute_sql(sql) | ||
|
|
||
| for col in columns: | ||
| type_ = "STRING" if col[1].startswith("STRING") else col[1] | ||
| if col[1].startswith("STRING"): | ||
| end = col[1].index(")") | ||
| size = int(col[1][7:end]) | ||
| type_ = _type_map["STRING"](length=size) | ||
| else: | ||
| type_ = _type_map[col[1]] | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While reflecting column types, we're reading strings like @larkee, I assume, something similar is required for BYTES (you mentioned their MAX size in the dialect), so I'm looking forward for BYTES types test. |
||
|
|
||
| cols_desc.append( | ||
| { | ||
| "name": col[0], | ||
| "type": _type_map[type_], | ||
| "type": type_, | ||
| "nullable": col[2] == "YES", | ||
| "default": None, | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Constant precision and scale