Skip to content

Commit 5b44eb2

Browse files
committed
fix schema error
1 parent 25e727c commit 5b44eb2

1 file changed

Lines changed: 8 additions & 17 deletions

File tree

sqlalchemy_datastore/base.py

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from ._types import _get_sqla_column_type
2828
from .parse_url import parse_url
2929

30-
from sqlalchemy.engine import default
30+
from sqlalchemy.engine import default, Connection
3131
from sqlalchemy import exc
3232
from sqlalchemy.sql import compiler
3333

@@ -431,26 +431,21 @@ def create_connect_args(self, url):
431431
self._client = client
432432
return ([], {"client": client})
433433

434-
def get_table_names(self, connection, schema=None, **kw):
435-
"""Retrieve table names from the database."""
436-
if isinstance(connection, Engine):
437-
connection = connection.connect()
434+
def get_schema_names(self, connection, **kw):
435+
return self.get_table_names(connection, None)
438436

439-
client = connection.connection._client
437+
def get_table_names(self, connection, schema: str | None = None, **kw):
438+
client = self._client
440439
query = client.query(kind="__kind__")
441-
query = query.keys_only()
442440
kinds = list(query.fetch())
443441
result = []
444442
for kind in kinds:
445443
result.append(kind.key.name)
446444
return result
447445

448-
def get_columns(self, connection, table_name, schema=None, **kw):
446+
def get_columns(connection: Connection, table_name: str, schema: str | None = None, **kw):
449447
"""Retrieve column information from the database."""
450-
if isinstance(connection, Engine):
451-
connection = connection.connect()
452-
453-
client = connection.connection._client
448+
client = self._client
454449
query = client.query(kind=table_name)
455450
ancestor_key = client.key("__kind__", table_name)
456451
query = client.query(kind="__property__", ancestor=ancestor_key)
@@ -461,11 +456,7 @@ def get_columns(self, connection, table_name, schema=None, **kw):
461456
columns.append(
462457
{
463458
"name": property.key.name,
464-
"type": _get_sqla_column_type(
465-
property.get("property_representation")[0]
466-
if property.get("property_representation", None) is not None
467-
else "STRING"
468-
),
459+
"type": _types.STRING, # FIXME: Prototype usage, change later
469460
"nullable": True,
470461
"comment": "",
471462
"default": None,

0 commit comments

Comments
 (0)