Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 2 additions & 11 deletions pydynamodb/sqlalchemy_dynamodb/pydynamodb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
import re
from ..util import strtobool
from typing import TYPE_CHECKING, Any, Callable, cast, Optional, Sequence, List
from typing import TYPE_CHECKING, cast, Optional, Sequence, List

import pydynamodb
from pydynamodb.error import OperationalError, NotSupportedError
Expand Down Expand Up @@ -566,6 +566,7 @@ def visit_delete(self, delete_stmt, **kw):


class DynamoDBTypeCompiler(GenericTypeCompiler):

def visit_FLOAT(self, type_, **kw):
return self.visit_REAL(type_, **kw)

Expand Down Expand Up @@ -622,16 +623,6 @@ class DynamoDBDialect(DefaultDialect):

_connect_options = dict() # type: ignore

def __init__(
self,
json_serializer: Optional[Callable[..., Any]] = None,
json_deserializer: Optional[Callable[..., Any]] = None,
**kwargs: Any,
) -> None:
DefaultDialect.__init__(self, **kwargs)
self._json_serializer = json_serializer
self._json_deserializer = json_deserializer

@classmethod
def dbapi(cls):
return pydynamodb
Expand Down
15 changes: 3 additions & 12 deletions tests/test_sqlalchemy_dynamodb.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from sqlalchemy.sql import text, select
from sqlalchemy.sql.schema import Column, MetaData, Table
from sqlalchemy import Integer, String, Numeric, JSON
from sqlalchemy import Integer, String, Numeric
from sqlalchemy.orm import declarative_base, Session

Base = declarative_base()
Expand All @@ -18,7 +18,6 @@ class _TestCase02(Base):
key_sort = Column(Integer, primary_key=True)
col_str = Column(String)
col_num = Column(Numeric)
col_json = Column(JSON)
col_nested = Column()

class _User(Base):
Expand Down Expand Up @@ -110,7 +109,7 @@ def test_nested_data_insert(self, engine):
"""
INSERT INTO "%s" VALUE {
'key_partition': :pk, 'key_sort': :sk,
'col_str': :col1, 'col_nested': :col2, 'col_json': :col3
'col_str': :col1, 'col_nested': :col2
}
"""
% TESTCASE02_TABLE
Expand All @@ -125,14 +124,13 @@ def test_nested_data_insert(self, engine):
"sk": 0,
"col1": "test case nested 0",
"col2": nested_data,
"col3": nested_data,
}
conn.execute(text(sql_one_row_2_0_), params_2_0_)

rows = conn.execute(
text(
"""
SELECT col_nested, col_json FROM %s WHERE key_partition = :pk
SELECT col_nested FROM %s WHERE key_partition = :pk
AND key_sort = :sk
"""
% TESTCASE02_TABLE
Expand All @@ -141,7 +139,6 @@ def test_nested_data_insert(self, engine):
).fetchall()
assert len(rows) == 1
assert rows[0][0] == nested_data
assert rows[0][1] == nested_data

def test_declarative_table_insert(self, engine):
engine, conn = engine
Expand Down Expand Up @@ -289,7 +286,6 @@ def test_nested_data_in_reflect_table(self, engine):
Column("key_sort", Integer),
Column("col_str", String),
Column("col_nested"),
Column("col_json", JSON),
)
rows = conn.execute(
table.select().where(
Expand All @@ -303,11 +299,6 @@ def test_nested_data_in_reflect_table(self, engine):
"Key2": {"Val2-1", "Val2-2"},
"Key3": "Val3",
}
assert rows[0].col_json == {
"Key1": ["Val1-1", 1, {"Subkey1": "Val1-1"}],
"Key2": {"Val2-1", "Val2-2"},
"Key3": "Val3",
}

def test_has_table_1(self, engine):
engine, conn = engine
Expand Down