Skip to content

Commit 49fcb65

Browse files
committed
Updated column introspection query to work with CockroachDB v22.2
The is_generated column in the information_schema changed from YES/NO to ALWAYS/NEVER.
1 parent 907693f commit 49fcb65

File tree

3 files changed

+25
-20
lines changed

3 files changed

+25
-20
lines changed

CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Unreleased
33

44
- Added `include_hidden` option to `get_columns()` to enable reflection of columns like "rowid". (#173)
55
- Added support for `.with_hint()` (patch courtesy of Jonathan Dieter)
6+
- Updated column introspection query to work with CockroachDB v22.2.
67

78
# Version 1.4.3
89
Released December 10, 2021

circle.yml

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
version: 2
22

3-
.x-cockroach-19.2: &cockroach-19-2
4-
image: cockroachdb/cockroach:v19.2.12
3+
.x-cockroach-21.1: &cockroach-21-1
4+
image: cockroachdb/cockroach:v21.1.19
55
command: start-single-node --insecure
66

7-
.x-cockroach-20.1: &cockroach-20-1
8-
image: cockroachdb/cockroach:v20.1.17
7+
.x-cockroach-21.2: &cockroach-21-2
8+
image: cockroachdb/cockroach:v21.2.15
99
command: start-single-node --insecure
1010

11-
.x-cockroach-20.2: &cockroach-20-2
12-
image: cockroachdb/cockroach:v20.2.11
11+
.x-cockroach-22.1: &cockroach-22-1
12+
image: cockroachdb/cockroach:v22.1.6
1313
command: start-single-node --insecure
1414

15-
.x-cockroach-21.1: &cockroach-21-1
16-
image: cockroachdb/cockroach:v21.1.2
15+
.x-cockroach-22.2: &cockroach-22-2
16+
image: cockroachdb/cockroach-unstable:v22.2.0-alpha.2
1717
command: start-single-node --insecure
1818

1919
.x-tox-version: &tox-version
@@ -38,31 +38,33 @@ version: 2
3838
command: ${HOME}/.local/bin/tox
3939

4040
jobs:
41-
test-py39-19.2:
41+
test-py39-21.1:
4242
docker:
4343
- image: circleci/python:3.9
44-
- *cockroach-19-2
44+
- *cockroach-21-1
4545
<<: *test-steps
4646
<<: *py39
4747

48-
test-py39-20.1:
48+
test-py39-21.2:
4949
docker:
5050
- image: circleci/python:3.9
51-
- *cockroach-20-1
51+
- *cockroach-21-2
5252
<<: *test-steps
5353
<<: *py39
5454

55-
test-py39-20.2:
55+
56+
test-py39-22.1:
5657
docker:
5758
- image: circleci/python:3.9
58-
- *cockroach-20-2
59+
- *cockroach-22-1
5960
<<: *test-steps
6061
<<: *py39
6162

62-
test-py39-21.1:
63+
64+
test-py39-22.2:
6365
docker:
6466
- image: circleci/python:3.9
65-
- *cockroach-21-1
67+
- *cockroach-22-2
6668
<<: *test-steps
6769
<<: *py39
6870

@@ -84,8 +86,8 @@ workflows:
8486
version: 2
8587
test-and-lint:
8688
jobs:
87-
- test-py39-19.2
88-
- test-py39-20.1
89-
- test-py39-20.2
9089
- test-py39-21.1
90+
- test-py39-21.2
91+
- test-py39-22.1
92+
- test-py39-22.2
9193
- lint

sqlalchemy_cockroachdb/base.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,9 @@ def get_columns(self, conn, table_name, schema=None, **kw):
209209
sql = (
210210
"SELECT column_name, data_type, is_nullable::bool, column_default, "
211211
"numeric_precision, numeric_scale, character_maximum_length, "
212-
"is_generated::bool, generation_expression, is_hidden::bool "
212+
"CASE is_generated WHEN 'ALWAYS' THEN true WHEN 'NEVER' THEN false "
213+
"ELSE is_generated::bool END AS is_generated, "
214+
"generation_expression, is_hidden::bool "
213215
"FROM information_schema.columns "
214216
"WHERE table_schema = :table_schema AND table_name = :table_name "
215217
)

0 commit comments

Comments
 (0)