|
12 | 12 | import pytest
|
13 | 13 | from conftest import get_engine
|
14 | 14 | from mock import patch
|
| 15 | +from sqlalchemy.exc import DBAPIError |
| 16 | + |
15 | 17 | from parameters import CONNECTION_PARAMETERS
|
16 |
| -from snowflake.connector import ProgrammingError, connect |
| 18 | +from snowflake.connector import ProgrammingError, connect, Error |
17 | 19 | from snowflake.sqlalchemy import URL, MergeInto, dialect
|
18 | 20 | from sqlalchemy import (
|
19 | 21 | REAL,
|
|
35 | 37 | )
|
36 | 38 | from sqlalchemy.sql import and_, not_, or_, select
|
37 | 39 |
|
| 40 | +from snowflake.sqlalchemy.snowdialect import SnowflakeDialect |
| 41 | + |
38 | 42 | try:
|
39 | 43 | from parameters import (CONNECTION_PARAMETERS2)
|
40 | 44 | except ImportError:
|
@@ -1233,8 +1237,32 @@ def test_too_many_columns_detection(engine_testaccount, db_parameters):
|
1233 | 1237 |
|
1234 | 1238 | def mock_helper(command, *args, **kwargs):
|
1235 | 1239 | if '_get_schema_columns' in command:
|
1236 |
| - raise ProgrammingError("Information schema query returned too much data. Please repeat query with more " |
1237 |
| - "selective predicates.", 90030) |
| 1240 | + # Creating exception exactly how SQLAlchemy does |
| 1241 | + raise DBAPIError.instance( |
| 1242 | + ''' |
| 1243 | + SELECT /* sqlalchemy:_get_schema_columns */ |
| 1244 | + ic.table_name, |
| 1245 | + ic.column_name, |
| 1246 | + ic.data_type, |
| 1247 | + ic.character_maximum_length, |
| 1248 | + ic.numeric_precision, |
| 1249 | + ic.numeric_scale, |
| 1250 | + ic.is_nullable, |
| 1251 | + ic.column_default, |
| 1252 | + ic.is_identity, |
| 1253 | + ic.comment |
| 1254 | + FROM information_schema.columns ic |
| 1255 | + WHERE ic.table_schema='schema_name' |
| 1256 | + ORDER BY ic.ordinal_position''', |
| 1257 | + {'table_schema': 'TESTSCHEMA'}, |
| 1258 | + ProgrammingError("Information schema query returned too much data. Please repeat query with more " |
| 1259 | + "selective predicates.", 90030), |
| 1260 | + Error, |
| 1261 | + hide_parameters=False, |
| 1262 | + connection_invalidated=False, |
| 1263 | + dialect=SnowflakeDialect(), |
| 1264 | + ismulti=None |
| 1265 | + ) |
1238 | 1266 | else:
|
1239 | 1267 | return original_execute(command, *args, **kwargs)
|
1240 | 1268 |
|
|
0 commit comments