-
-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add date32 type * Add date32 type * Fix * Flake linting fix * Set required server version to 21_9 * Lint * Fix test
- Loading branch information
1 parent
83c5b46
commit 7ad94b0
Showing
5 changed files
with
56 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import datetime | ||
|
||
from sqlalchemy import Column | ||
from sqlalchemy.sql.ddl import CreateTable | ||
|
||
from clickhouse_sqlalchemy import types, engines, Table | ||
from tests.testcase import BaseTestCase, CompilationTestCase | ||
from tests.util import with_native_and_http_sessions | ||
|
||
|
||
class Date32CompilationTestCase(CompilationTestCase): | ||
required_server_version = (21, 9, 0) | ||
|
||
def test_create_table(self): | ||
table = Table( | ||
'test', CompilationTestCase.metadata(), | ||
Column('x', types.Date32, primary_key=True), | ||
engines.Memory() | ||
) | ||
|
||
self.assertEqual( | ||
self.compile(CreateTable(table)), | ||
'CREATE TABLE test (x Date32) ENGINE = Memory' | ||
) | ||
|
||
|
||
@with_native_and_http_sessions | ||
class Date32TestCase(BaseTestCase): | ||
required_server_version = (21, 9, 0) | ||
|
||
table = Table( | ||
'test', BaseTestCase.metadata(), | ||
Column('x', types.Date32, primary_key=True), | ||
engines.Memory() | ||
) | ||
|
||
def test_select_insert(self): | ||
# Use a date before epoch to validate dates before epoch can be stored. | ||
date = datetime.date(1925, 1, 1) | ||
with self.create_table(self.table): | ||
self.session.execute(self.table.insert(), [{'x': date}]) | ||
result = self.session.execute(self.table.select()).scalar() | ||
if isinstance(result, datetime.date): | ||
self.assertEqual(result, date) | ||
else: | ||
self.assertEqual(result, date.isoformat()) |