wireservice / agate-sql

agate-sql adds SQL read/write support to agate.
https://agate-sql.readthedocs.io
MIT License
18 stars 15 forks source link

TestSQL.test_to_sql_create_statement_with_schema fails #33

Closed mcepl closed 3 years ago

mcepl commented 3 years ago

When packaging agate-sql for openSUSE, the test suite fails with this failure (using Python 3.6):

[   25s] + pytest-3.6 --ignore=_build.python36 --ignore=_build.python38 -v
[   25s] ============================= test session starts ==============================
[   25s] platform linux -- Python 3.6.12, pytest-6.2.2, py-1.9.0, pluggy-0.13.1 -- /usr/bin/python3.6
[   25s] cachedir: .pytest_cache
[   25s] rootdir: /home/abuild/rpmbuild/BUILD/agate-sql-0.5.5
[   25s] collecting ... collected 18 items
[   25s]
[   26s] tests/test_agatesql.py::TestSQL::test_back_and_forth PASSED              [  5%]
[   26s] tests/test_agatesql.py::TestSQL::test_chunk_size PASSED                  [ 11%]
[   26s] tests/test_agatesql.py::TestSQL::test_create_if_not_exists PASSED        [ 16%]
[   26s] tests/test_agatesql.py::TestSQL::test_make_sql_table_col_len_multiplier PASSED [ 22%]
[   26s] tests/test_agatesql.py::TestSQL::test_make_sql_table_min_col_len PASSED  [ 27%]
[   26s] tests/test_agatesql.py::TestSQL::test_prefixes PASSED                    [ 33%]
[   26s] tests/test_agatesql.py::TestSQL::test_sql_query_aggregate PASSED         [ 38%]
[   26s] tests/test_agatesql.py::TestSQL::test_sql_query_limit PASSED             [ 44%]
[   26s] tests/test_agatesql.py::TestSQL::test_sql_query_select PASSED            [ 50%]
[   26s] tests/test_agatesql.py::TestSQL::test_sql_query_simple PASSED            [ 55%]
[   26s] tests/test_agatesql.py::TestSQL::test_to_sql_create_statement PASSED     [ 61%]
[   26s] tests/test_agatesql.py::TestSQL::test_to_sql_create_statement_no_constraints PASSED [ 66%]
[   26s] tests/test_agatesql.py::TestSQL::test_to_sql_create_statement_unique_constraint PASSED [ 72%]
[   26s] tests/test_agatesql.py::TestSQL::test_to_sql_create_statement_wide_width PASSED [ 77%]
[   26s] tests/test_agatesql.py::TestSQL::test_to_sql_create_statement_with_dialects PASSED [ 83%]
[   26s] tests/test_agatesql.py::TestSQL::test_to_sql_create_statement_with_schema FAILED [ 88%]
[   26s] tests/test_agatesql.py::TestSQL::test_to_sql_create_statement_zero_width PASSED [ 94%]
[   26s] tests/test_agatesql.py::TestSQL::test_unique_constraint PASSED           [100%]
[   26s]
[   26s] =================================== FAILURES ===================================
[   26s] _______________ TestSQL.test_to_sql_create_statement_with_schema _______________
[   26s]
[   26s] self = <tests.test_agatesql.TestSQL testMethod=test_to_sql_create_statement_with_schema>
[   26s]
[   26s]         def test_to_sql_create_statement_with_schema(self):
[   26s]             statement = self.table.to_sql_create_statement('test_table', db_schema='test_schema', dialect='mysql')
[   26s]
[   26s]             self.assertEqual(statement.replace('\t', '  '), '''CREATE TABLE test_schema.test_table (
[   26s]       number DECIMAL(38, 3),
[   26s]       text VARCHAR(1) NOT NULL,
[   26s]       boolean BOOL,
[   26s]       date DATE,
[   26s]       datetime TIMESTAMP NULL,
[   26s]       CHECK (boolean IN (0, 1))
[   26s] >   );''')  # noqa
[   26s] E   AssertionError: 'CREA[59 chars] \n  `text` VARCHAR(1) NOT NULL, \n  boolean B[78 chars]\n);' != 'CREA[59 chars] \n  text VARCHAR(1) NOT NULL, \n  boolean BOO[76 chars]\n);
'
[   26s] E     CREATE TABLE test_schema.test_table (
[   26s] E       number DECIMAL(38, 3),
[   26s] E   -   `text` VARCHAR(1) NOT NULL,
[   26s] E   ?   -    -
[   26s] E   +   text VARCHAR(1) NOT NULL,
[   26s] E       boolean BOOL,
[   26s] E       date DATE,
[   26s] E       datetime TIMESTAMP NULL,
[   26s] E       CHECK (boolean IN (0, 1))
[   26s] E     );
[   26s]
[   26s] tests/test_agatesql.py:149: AssertionError
[   26s] =============================== warnings summary ===============================
[   26s] tests/test_agatesql.py::TestSQL::test_make_sql_table_col_len_multiplier
[   26s]   /home/abuild/rpmbuild/BUILD/agate-sql-0.5.5/tests/test_agatesql.py:191: DeprecationWarning: Please use assertEqual instead.
[   26s]
[   26s] tests/test_agatesql.py::TestSQL::test_make_sql_table_min_col_len
[   26s]   /home/abuild/rpmbuild/BUILD/agate-sql-0.5.5/tests/test_agatesql.py:203: DeprecationWarning: Please use assertEqual instead.
[   26s]
[   26s] -- Docs: https://docs.pytest.org/en/stable/warnings.html
[   26s] =========================== short test summary info ============================
[   26s] FAILED tests/test_agatesql.py::TestSQL::test_to_sql_create_statement_with_schema
[   26s] =================== 1 failed, 17 passed, 2 warnings in 0.54s ===================

Full build log with all details of the process and versions of all packages used.

jpmckinney commented 3 years ago

I think I've now corrected this issue in version 0.5.6.

MeggyCal commented 3 years ago

Hi, the test still fails in 0.5.6, but with a slightly different message:

[   25s] =================================== FAILURES ===================================
[   25s] _______________ TestSQL.test_to_sql_create_statement_with_schema _______________
[   25s] 
[   25s] self = <tests.test_agatesql.TestSQL testMethod=test_to_sql_create_statement_with_schema>
[   25s] 
[   25s]         def test_to_sql_create_statement_with_schema(self):
[   25s]             statement = self.table.to_sql_create_statement('test_table', db_schema='test_schema', dialect='mysql')
[   25s]     
[   25s]             self.assertEqual(statement.replace('\t', '  '), '''CREATE TABLE test_schema.test_table (
[   25s]       number DECIMAL(38, 3),
[   25s]       textcol VARCHAR(1) NOT NULL,
[   25s]       boolean BOOL,
[   25s]       date DATE,
[   25s]       datetime TIMESTAMP NULL,
[   25s]       CHECK (boolean IN (0, 1))
[   25s] >   );''')  # noqa
[   25s] E   AssertionError: 'CREA[126 chars]\n  datetime TIMESTAMP NULL\n);' != 'CREA[126 chars]\n  datetime TIMESTAMP NULL, \n  CHECK (boolean IN (0, 1))\n);'
[   25s] E     CREATE TABLE test_schema.test_table (
[   25s] E       number DECIMAL(38, 3), 
[   25s] E       textcol VARCHAR(1) NOT NULL, 
[   25s] E       boolean BOOL, 
[   25s] E       date DATE, 
[   25s] E   -   datetime TIMESTAMP NULL
[   25s] E   +   datetime TIMESTAMP NULL, 
[   25s] E   ?                          ++
[   25s] E   +   CHECK (boolean IN (0, 1))
[   25s] E     );
[   25s] 
mcepl commented 3 years ago

Confirming https://github.com/wireservice/agate-sql/issues/33#issuecomment-871252304 . Please, reopen.

jpmckinney commented 3 years ago

Confirmed in CI: https://github.com/wireservice/agate-sql/runs/3051849209

jpmckinney commented 3 years ago

Fixed. Thanks for reporting!

MeggyCal commented 3 years ago

thanks a lot! I think the failure was due to new version of something, it would be eventually nice to find out what changed and document it if you find some spare time :)

jpmckinney commented 3 years ago

Yes, I plan to dig into it - it's not clear what changed.

jpmckinney commented 3 years ago

It looks like SQLAlchemy used to add a constraint on boolean fields, but possibly, in the MySQL dialect used by the test, such a constraint is not mandatory.