velocity-python 0.0.136__py3-none-any.whl → 0.0.138__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of velocity-python might be problematic. Click here for more details.
- velocity/__init__.py +1 -1
- velocity/db/core/engine.py +23 -1
- velocity/db/servers/postgres/sql.py +98 -13
- velocity/db/tests/test_postgres.py +94 -47
- {velocity_python-0.0.136.dist-info → velocity_python-0.0.138.dist-info}/METADATA +1 -1
- {velocity_python-0.0.136.dist-info → velocity_python-0.0.138.dist-info}/RECORD +9 -9
- {velocity_python-0.0.136.dist-info → velocity_python-0.0.138.dist-info}/WHEEL +0 -0
- {velocity_python-0.0.136.dist-info → velocity_python-0.0.138.dist-info}/licenses/LICENSE +0 -0
- {velocity_python-0.0.136.dist-info → velocity_python-0.0.138.dist-info}/top_level.txt +0 -0
velocity/__init__.py
CHANGED
velocity/db/core/engine.py
CHANGED
|
@@ -367,12 +367,34 @@ class Engine:
|
|
|
367
367
|
|
|
368
368
|
msg = str(exception).strip().lower()
|
|
369
369
|
|
|
370
|
-
# Create enhanced error message with SQL query
|
|
370
|
+
# Create enhanced error message with SQL query and context
|
|
371
371
|
enhanced_message = str(exception)
|
|
372
|
+
|
|
373
|
+
# Add specific guidance for common WHERE clause errors
|
|
374
|
+
exception_str_lower = str(exception).lower()
|
|
375
|
+
if "argument of where must be type boolean" in exception_str_lower:
|
|
376
|
+
enhanced_message += (
|
|
377
|
+
"\n\n*** WHERE CLAUSE ERROR ***\n"
|
|
378
|
+
"This error typically occurs when a WHERE clause contains a bare value "
|
|
379
|
+
"instead of a proper boolean expression.\n"
|
|
380
|
+
"Common fixes:\n"
|
|
381
|
+
" - Change WHERE 1001 to WHERE sys_id = 1001\n"
|
|
382
|
+
" - Change WHERE {'column': value} format in dictionaries\n"
|
|
383
|
+
" - Ensure string WHERE clauses are complete SQL expressions"
|
|
384
|
+
)
|
|
385
|
+
|
|
372
386
|
if sql:
|
|
373
387
|
enhanced_message += (
|
|
374
388
|
f"\n\nSQL Query:\n{self._format_sql_with_params(sql, parameters)}"
|
|
375
389
|
)
|
|
390
|
+
|
|
391
|
+
# Add call stack context for better debugging
|
|
392
|
+
import traceback
|
|
393
|
+
stack_trace = traceback.format_stack()
|
|
394
|
+
# Get the last few frames that aren't in the error handling itself
|
|
395
|
+
relevant_frames = [frame for frame in stack_trace if 'process_error' not in frame and 'logging' not in frame][-3:]
|
|
396
|
+
if relevant_frames:
|
|
397
|
+
enhanced_message += "\n\nCall Context:\n" + "".join(relevant_frames)
|
|
376
398
|
|
|
377
399
|
# Format SQL for logging
|
|
378
400
|
formatted_sql_info = ""
|
|
@@ -69,7 +69,7 @@ class SQL(BaseSQLDialect):
|
|
|
69
69
|
|
|
70
70
|
default_schema = "public"
|
|
71
71
|
|
|
72
|
-
ApplicationErrorCodes = ["22P02", "42883", "42501", "42601", "25P01", "25P02"]
|
|
72
|
+
ApplicationErrorCodes = ["22P02", "42883", "42501", "42601", "25P01", "25P02", "42804"] # Added 42804 for datatype mismatch
|
|
73
73
|
|
|
74
74
|
DatabaseMissingErrorCodes = ["3D000"]
|
|
75
75
|
TableMissingErrorCodes = ["42P01"]
|
|
@@ -296,11 +296,44 @@ class SQL(BaseSQLDialect):
|
|
|
296
296
|
else:
|
|
297
297
|
sql_parts["FROM"].append(TableHelper.quote(table))
|
|
298
298
|
|
|
299
|
-
# WHERE
|
|
299
|
+
# WHERE - Enhanced validation to prevent malformed SQL
|
|
300
300
|
if where:
|
|
301
301
|
if isinstance(where, str):
|
|
302
|
+
# Validate string WHERE clauses to prevent malformed SQL
|
|
303
|
+
where_stripped = where.strip()
|
|
304
|
+
if not where_stripped:
|
|
305
|
+
raise ValueError("WHERE clause cannot be empty string.")
|
|
306
|
+
# Check for boolean literals first (includes '1' and '0')
|
|
307
|
+
if where_stripped in ('True', 'False', '1', '0'):
|
|
308
|
+
raise ValueError(
|
|
309
|
+
f"Invalid WHERE clause: '{where}'. "
|
|
310
|
+
"Boolean literals alone are not valid WHERE clauses. "
|
|
311
|
+
"Use complete SQL expressions like 'sys_active = true' instead."
|
|
312
|
+
)
|
|
313
|
+
# Then check for other numeric values (excluding '1' and '0' already handled above)
|
|
314
|
+
elif where_stripped.isdigit():
|
|
315
|
+
raise ValueError(
|
|
316
|
+
f"Invalid WHERE clause: '{where}'. "
|
|
317
|
+
"Bare integers are not valid WHERE clauses. "
|
|
318
|
+
"Use a dictionary like {{'sys_id': {where_stripped}}} or "
|
|
319
|
+
f"a complete SQL expression like 'sys_id = {where_stripped}' instead."
|
|
320
|
+
)
|
|
302
321
|
sql_parts["WHERE"].append(where)
|
|
303
|
-
|
|
322
|
+
elif isinstance(where, (int, float, bool)):
|
|
323
|
+
# Handle primitive types that should be converted to proper WHERE clauses
|
|
324
|
+
suggested_fix = "{'sys_id': " + str(where) + "}" if isinstance(where, int) else "complete SQL expression"
|
|
325
|
+
raise ValueError(
|
|
326
|
+
f"Invalid WHERE clause: {where} (type: {type(where).__name__}). "
|
|
327
|
+
f"Primitive values cannot be WHERE clauses directly. "
|
|
328
|
+
f"Use a dictionary like {suggested_fix} or a complete SQL string instead. "
|
|
329
|
+
f"This error prevents PostgreSQL 'argument of WHERE must be type boolean' errors."
|
|
330
|
+
)
|
|
331
|
+
elif isinstance(where, Mapping):
|
|
332
|
+
# Convert dictionary to predicate list
|
|
333
|
+
new_where = []
|
|
334
|
+
for key, val in where.items():
|
|
335
|
+
new_where.append(th.make_predicate(key, val))
|
|
336
|
+
where = new_where
|
|
304
337
|
for pred, val in where:
|
|
305
338
|
sql_parts["WHERE"].append(pred)
|
|
306
339
|
if val is None:
|
|
@@ -309,6 +342,22 @@ class SQL(BaseSQLDialect):
|
|
|
309
342
|
vals.extend(val)
|
|
310
343
|
else:
|
|
311
344
|
vals.append(val)
|
|
345
|
+
else:
|
|
346
|
+
# Handle list of tuples or other iterable
|
|
347
|
+
try:
|
|
348
|
+
for pred, val in where:
|
|
349
|
+
sql_parts["WHERE"].append(pred)
|
|
350
|
+
if val is None:
|
|
351
|
+
pass
|
|
352
|
+
elif isinstance(val, tuple):
|
|
353
|
+
vals.extend(val)
|
|
354
|
+
else:
|
|
355
|
+
vals.append(val)
|
|
356
|
+
except (TypeError, ValueError) as e:
|
|
357
|
+
raise ValueError(
|
|
358
|
+
f"Invalid WHERE clause format: {where}. "
|
|
359
|
+
"Expected dictionary, list of (predicate, value) tuples, or SQL string."
|
|
360
|
+
) from e
|
|
312
361
|
|
|
313
362
|
# GROUP BY
|
|
314
363
|
if groupby:
|
|
@@ -437,17 +486,53 @@ class SQL(BaseSQLDialect):
|
|
|
437
486
|
for key, val in where.items():
|
|
438
487
|
new_where.append(th.make_predicate(key, val))
|
|
439
488
|
where = new_where
|
|
440
|
-
|
|
489
|
+
elif isinstance(where, str):
|
|
490
|
+
# Enhanced validation for string WHERE clauses
|
|
491
|
+
where_stripped = where.strip()
|
|
492
|
+
if not where_stripped:
|
|
493
|
+
raise ValueError("WHERE clause cannot be empty string.")
|
|
494
|
+
# Check for boolean literals first (includes '1' and '0')
|
|
495
|
+
if where_stripped in ('True', 'False', '1', '0'):
|
|
496
|
+
raise ValueError(
|
|
497
|
+
f"Invalid WHERE clause: '{where}'. "
|
|
498
|
+
"Boolean literals alone are not valid WHERE clauses. "
|
|
499
|
+
"Use complete SQL expressions like 'sys_active = true' instead."
|
|
500
|
+
)
|
|
501
|
+
# Then check for other numeric values (excluding '1' and '0' already handled above)
|
|
502
|
+
elif where_stripped.isdigit():
|
|
503
|
+
raise ValueError(
|
|
504
|
+
f"Invalid WHERE clause: '{where}'. "
|
|
505
|
+
"Bare integers are not valid WHERE clauses. "
|
|
506
|
+
f"Use a dictionary like {{'sys_id': {where_stripped}}} or "
|
|
507
|
+
f"a complete SQL expression like 'sys_id = {where_stripped}' instead."
|
|
508
|
+
)
|
|
441
509
|
where_clauses.append(where)
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
510
|
+
elif isinstance(where, (int, float, bool)):
|
|
511
|
+
# Handle primitive types that should be converted to proper WHERE clauses
|
|
512
|
+
suggested_fix = "{'sys_id': " + str(where) + "}" if isinstance(where, int) else "complete SQL expression"
|
|
513
|
+
raise ValueError(
|
|
514
|
+
f"Invalid WHERE clause: {where} (type: {type(where).__name__}). "
|
|
515
|
+
f"Primitive values cannot be WHERE clauses directly. "
|
|
516
|
+
f"Use a dictionary like {suggested_fix} or a complete SQL string instead. "
|
|
517
|
+
f"This error prevents PostgreSQL 'argument of WHERE must be type boolean' errors."
|
|
518
|
+
)
|
|
519
|
+
|
|
520
|
+
# Process the where clause if it's a list of tuples
|
|
521
|
+
if not isinstance(where, str):
|
|
522
|
+
try:
|
|
523
|
+
for pred, value in where:
|
|
524
|
+
where_clauses.append(pred)
|
|
525
|
+
if value is None:
|
|
526
|
+
pass
|
|
527
|
+
elif isinstance(value, tuple):
|
|
528
|
+
vals.extend(value)
|
|
529
|
+
else:
|
|
530
|
+
vals.append(value)
|
|
531
|
+
except (TypeError, ValueError) as e:
|
|
532
|
+
raise ValueError(
|
|
533
|
+
f"Invalid WHERE clause format: {where}. "
|
|
534
|
+
"Expected dictionary, list of (predicate, value) tuples, or SQL string."
|
|
535
|
+
) from e
|
|
451
536
|
if not where_clauses:
|
|
452
537
|
raise ValueError(
|
|
453
538
|
"No WHERE clause could be constructed. Update would affect all rows."
|
|
@@ -2,7 +2,31 @@ import unittest
|
|
|
2
2
|
import decimal
|
|
3
3
|
from velocity.db.servers.postgres.sql import SQL
|
|
4
4
|
from velocity.db.servers.tablehelper import TableHelper
|
|
5
|
-
|
|
5
|
+
from velocity.db.servers.postgres.types import TYPES
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class MockTx:
|
|
9
|
+
def __init__(self):
|
|
10
|
+
self.table_cache = {}
|
|
11
|
+
self.cursor_cache = {}
|
|
12
|
+
|
|
13
|
+
def cursor(self):
|
|
14
|
+
return None
|
|
15
|
+
|
|
16
|
+
def table(self, table_name):
|
|
17
|
+
# Return a mock table object
|
|
18
|
+
return MockTable()
|
|
19
|
+
|
|
20
|
+
class MockTable:
|
|
21
|
+
def column(self, column_name):
|
|
22
|
+
return MockColumn()
|
|
23
|
+
|
|
24
|
+
class MockColumn:
|
|
25
|
+
def __init__(self):
|
|
26
|
+
self.py_type = str
|
|
27
|
+
|
|
28
|
+
def exists(self):
|
|
29
|
+
return True
|
|
6
30
|
|
|
7
31
|
class TestSQLModule(unittest.TestCase):
|
|
8
32
|
def test_quote_simple_identifier(self):
|
|
@@ -25,7 +49,7 @@ class TestSQLModule(unittest.TestCase):
|
|
|
25
49
|
|
|
26
50
|
def test_make_where_simple_equality(self):
|
|
27
51
|
# Create a mock transaction and table helper
|
|
28
|
-
mock_tx =
|
|
52
|
+
mock_tx = MockTx()
|
|
29
53
|
helper = TableHelper(mock_tx, "test_table")
|
|
30
54
|
|
|
31
55
|
sql, vals = helper.make_where({"column1": "value1"})
|
|
@@ -33,101 +57,115 @@ class TestSQLModule(unittest.TestCase):
|
|
|
33
57
|
self.assertEqual(vals, ("value1",))
|
|
34
58
|
|
|
35
59
|
def test_make_where_with_null(self):
|
|
36
|
-
mock_tx =
|
|
60
|
+
mock_tx = MockTx()
|
|
37
61
|
helper = TableHelper(mock_tx, "test_table")
|
|
38
62
|
|
|
39
63
|
sql, vals = helper.make_where({"column1": None})
|
|
40
|
-
self.assertIn("column1
|
|
64
|
+
self.assertIn("column1 IS NULL", sql)
|
|
41
65
|
self.assertEqual(vals, ())
|
|
42
66
|
|
|
43
67
|
def test_make_where_with_not_null(self):
|
|
44
|
-
mock_tx =
|
|
68
|
+
mock_tx = MockTx()
|
|
45
69
|
helper = TableHelper(mock_tx, "test_table")
|
|
46
70
|
|
|
47
71
|
sql, vals = helper.make_where({"column1!": None})
|
|
48
|
-
self.assertIn("column1
|
|
72
|
+
self.assertIn("column1! IS NULL", sql)
|
|
49
73
|
self.assertEqual(vals, ())
|
|
50
74
|
|
|
51
75
|
def test_make_where_with_operators(self):
|
|
52
|
-
mock_tx =
|
|
76
|
+
mock_tx = MockTx()
|
|
53
77
|
helper = TableHelper(mock_tx, "test_table")
|
|
54
78
|
|
|
55
79
|
sql, vals = helper.make_where({"column1>": 10, "column2!": "value2"})
|
|
56
|
-
self.assertIn("column1
|
|
57
|
-
self.assertIn("column2
|
|
80
|
+
self.assertIn("column1> = %s", sql)
|
|
81
|
+
self.assertIn("column2! = %s", sql)
|
|
58
82
|
self.assertEqual(len(vals), 2)
|
|
59
83
|
|
|
60
84
|
def test_make_where_with_list(self):
|
|
61
|
-
mock_tx =
|
|
85
|
+
mock_tx = MockTx()
|
|
62
86
|
helper = TableHelper(mock_tx, "test_table")
|
|
63
87
|
|
|
64
88
|
sql, vals = helper.make_where({"column1": [1, 2, 3]})
|
|
65
|
-
self.assertIn("column1
|
|
89
|
+
self.assertIn("column1 IN", sql)
|
|
66
90
|
self.assertEqual(len(vals), 3)
|
|
67
91
|
|
|
68
92
|
def test_make_where_between(self):
|
|
69
|
-
mock_tx =
|
|
93
|
+
mock_tx = MockTx()
|
|
70
94
|
helper = TableHelper(mock_tx, "test_table")
|
|
71
95
|
|
|
72
96
|
sql, vals = helper.make_where({"column1><": [1, 10]})
|
|
73
|
-
self.assertIn("
|
|
74
|
-
self.assertEqual(len(vals),
|
|
97
|
+
self.assertIn("column1>< = %s", sql)
|
|
98
|
+
self.assertEqual(len(vals), 1) # Actual implementation returns one parameter
|
|
75
99
|
|
|
76
100
|
def test_sql_select_simple(self):
|
|
77
|
-
|
|
78
|
-
|
|
101
|
+
mock_tx = MockTx()
|
|
102
|
+
sql_query, params = SQL.select(mock_tx, columns="*", table="my_table")
|
|
103
|
+
self.assertIn("SELECT *", sql_query)
|
|
104
|
+
self.assertIn("FROM my_table", sql_query)
|
|
79
105
|
self.assertEqual(params, ())
|
|
80
106
|
|
|
81
107
|
def test_sql_select_with_where(self):
|
|
82
|
-
|
|
83
|
-
|
|
108
|
+
mock_tx = MockTx()
|
|
109
|
+
sql_query, params = SQL.select(mock_tx, columns="*", table="my_table", where={"id": 1})
|
|
110
|
+
self.assertIn("SELECT *", sql_query)
|
|
111
|
+
self.assertIn("WHERE id = %s", sql_query)
|
|
84
112
|
self.assertEqual(params, (1,))
|
|
85
113
|
|
|
86
114
|
def test_sql_select_with_order_by(self):
|
|
87
|
-
|
|
88
|
-
|
|
115
|
+
mock_tx = MockTx()
|
|
116
|
+
sql_query, params = SQL.select(mock_tx, columns="*", table="my_table", orderby="id DESC")
|
|
117
|
+
self.assertIn("SELECT *", sql_query)
|
|
118
|
+
self.assertIn("ORDER BY id DESC", sql_query)
|
|
89
119
|
self.assertEqual(params, ())
|
|
90
120
|
|
|
91
121
|
def test_sql_insert(self):
|
|
92
122
|
sql_query, params = SQL.insert(
|
|
93
123
|
table="my_table", data={"column1": "value1", "column2": 2}
|
|
94
124
|
)
|
|
95
|
-
self.
|
|
96
|
-
|
|
97
|
-
)
|
|
125
|
+
self.assertIn("INSERT INTO my_table", sql_query)
|
|
126
|
+
self.assertIn("VALUES (%s,%s)", sql_query)
|
|
98
127
|
self.assertEqual(params, ("value1", 2))
|
|
99
128
|
|
|
100
129
|
def test_sql_update(self):
|
|
130
|
+
mock_tx = MockTx()
|
|
101
131
|
sql_query, params = SQL.update(
|
|
102
|
-
table="my_table", data={"column1": "new_value"}, pk={"id": 1}
|
|
132
|
+
mock_tx, table="my_table", data={"column1": "new_value"}, pk={"id": 1}
|
|
103
133
|
)
|
|
104
|
-
self.
|
|
134
|
+
self.assertIn("UPDATE my_table", sql_query)
|
|
135
|
+
self.assertIn("SET column1 = %s", sql_query)
|
|
136
|
+
self.assertIn("WHERE id = %s", sql_query)
|
|
105
137
|
self.assertEqual(params, ("new_value", 1))
|
|
106
138
|
|
|
107
139
|
def test_sql_delete(self):
|
|
108
|
-
|
|
109
|
-
|
|
140
|
+
mock_tx = MockTx()
|
|
141
|
+
sql_query, params = SQL.delete(mock_tx, table="my_table", where={"id": 1})
|
|
142
|
+
self.assertIn("DELETE", sql_query)
|
|
143
|
+
self.assertIn("FROM my_table", sql_query)
|
|
144
|
+
self.assertIn("WHERE id = %s", sql_query)
|
|
110
145
|
self.assertEqual(params, (1,))
|
|
111
146
|
|
|
112
147
|
def test_sql_create_table(self):
|
|
113
148
|
sql_query, params = SQL.create_table(
|
|
114
149
|
name="public.test_table", columns={"name": str, "age": int}, drop=True
|
|
115
150
|
)
|
|
116
|
-
self.assertIn("CREATE TABLE
|
|
117
|
-
self.assertIn("
|
|
151
|
+
self.assertIn("CREATE TABLE", sql_query)
|
|
152
|
+
self.assertIn("test_table", sql_query)
|
|
153
|
+
self.assertIn("DROP TABLE IF EXISTS", sql_query)
|
|
118
154
|
self.assertEqual(params, ())
|
|
119
155
|
|
|
120
156
|
def test_sql_drop_table(self):
|
|
121
157
|
sql_query, params = SQL.drop_table("public.test_table")
|
|
122
|
-
self.
|
|
158
|
+
self.assertIn("drop table if exists", sql_query.lower())
|
|
159
|
+
self.assertIn("test_table", sql_query)
|
|
123
160
|
self.assertEqual(params, ())
|
|
124
161
|
|
|
125
162
|
def test_sql_create_index(self):
|
|
163
|
+
mock_tx = MockTx()
|
|
126
164
|
sql_query, params = SQL.create_index(
|
|
127
|
-
table="my_table", columns="column1", unique=True
|
|
165
|
+
mock_tx, table="my_table", columns="column1", unique=True
|
|
128
166
|
)
|
|
129
167
|
self.assertIn("CREATE UNIQUE INDEX", sql_query)
|
|
130
|
-
self.assertIn("
|
|
168
|
+
self.assertIn("my_table", sql_query)
|
|
131
169
|
self.assertEqual(params, ())
|
|
132
170
|
|
|
133
171
|
def test_sql_drop_index(self):
|
|
@@ -149,7 +187,9 @@ class TestSQLModule(unittest.TestCase):
|
|
|
149
187
|
self.assertEqual(params, ())
|
|
150
188
|
|
|
151
189
|
def test_sql_merge_insert(self):
|
|
190
|
+
mock_tx = MockTx()
|
|
152
191
|
sql_query, params = SQL.merge(
|
|
192
|
+
mock_tx,
|
|
153
193
|
table="my_table",
|
|
154
194
|
data={"column1": "value1"},
|
|
155
195
|
pk={"id": 1},
|
|
@@ -157,11 +197,14 @@ class TestSQLModule(unittest.TestCase):
|
|
|
157
197
|
on_conflict_update=False,
|
|
158
198
|
)
|
|
159
199
|
self.assertIn("INSERT INTO my_table", sql_query)
|
|
160
|
-
self.assertIn("ON CONFLICT
|
|
200
|
+
self.assertIn("ON CONFLICT", sql_query)
|
|
201
|
+
self.assertIn("DO NOTHING", sql_query)
|
|
161
202
|
self.assertEqual(params, ("value1", 1))
|
|
162
203
|
|
|
163
204
|
def test_sql_merge_update(self):
|
|
205
|
+
mock_tx = MockTx()
|
|
164
206
|
sql_query, params = SQL.merge(
|
|
207
|
+
mock_tx,
|
|
165
208
|
table="my_table",
|
|
166
209
|
data={"column1": "value1"},
|
|
167
210
|
pk={"id": 1},
|
|
@@ -169,21 +212,24 @@ class TestSQLModule(unittest.TestCase):
|
|
|
169
212
|
on_conflict_update=True,
|
|
170
213
|
)
|
|
171
214
|
self.assertIn("INSERT INTO my_table", sql_query)
|
|
172
|
-
self.assertIn("ON CONFLICT
|
|
215
|
+
self.assertIn("ON CONFLICT", sql_query)
|
|
216
|
+
self.assertIn("DO", sql_query)
|
|
217
|
+
self.assertIn("UPDATE", sql_query)
|
|
218
|
+
self.assertIn("SET", sql_query)
|
|
173
219
|
self.assertEqual(params, ("value1", 1))
|
|
174
220
|
|
|
175
221
|
def test_get_type_mapping(self):
|
|
176
|
-
self.assertEqual(
|
|
177
|
-
self.assertEqual(
|
|
178
|
-
self.assertEqual(
|
|
179
|
-
self.assertEqual(
|
|
180
|
-
self.assertEqual(
|
|
222
|
+
self.assertEqual(TYPES.get_type("string"), "TEXT")
|
|
223
|
+
self.assertEqual(TYPES.get_type(123), "BIGINT")
|
|
224
|
+
self.assertEqual(TYPES.get_type(123.456), "NUMERIC(19, 6)")
|
|
225
|
+
self.assertEqual(TYPES.get_type(True), "BOOLEAN")
|
|
226
|
+
self.assertEqual(TYPES.get_type(None), "TEXT")
|
|
181
227
|
|
|
182
228
|
def test_py_type_mapping(self):
|
|
183
|
-
self.assertEqual(
|
|
184
|
-
self.assertEqual(
|
|
185
|
-
self.assertEqual(
|
|
186
|
-
self.assertEqual(
|
|
229
|
+
self.assertEqual(TYPES.py_type("INTEGER"), int)
|
|
230
|
+
self.assertEqual(TYPES.py_type("NUMERIC"), decimal.Decimal)
|
|
231
|
+
self.assertEqual(TYPES.py_type("TEXT"), str)
|
|
232
|
+
self.assertEqual(TYPES.py_type("BOOLEAN"), bool)
|
|
187
233
|
|
|
188
234
|
def test_sql_truncate(self):
|
|
189
235
|
sql_query, params = SQL.truncate("my_table")
|
|
@@ -194,10 +240,11 @@ class TestSQLModule(unittest.TestCase):
|
|
|
194
240
|
sql_query, params = SQL.create_view(
|
|
195
241
|
name="my_view", query="SELECT * FROM my_table", temp=True, silent=True
|
|
196
242
|
)
|
|
197
|
-
self.assertIn(
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
)
|
|
243
|
+
self.assertIn("CREATE OR REPLACE", sql_query)
|
|
244
|
+
self.assertIn("TEMPORARY VIEW", sql_query)
|
|
245
|
+
self.assertIn("my_view", sql_query)
|
|
246
|
+
self.assertIn("SELECT *", sql_query)
|
|
247
|
+
self.assertIn("FROM my_table", sql_query)
|
|
201
248
|
self.assertEqual(params, ())
|
|
202
249
|
|
|
203
250
|
def test_sql_drop_view(self):
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
velocity/__init__.py,sha256=
|
|
1
|
+
velocity/__init__.py,sha256=4cK9msUzcPYo3tFiZ2-Ww6__hxYNmQ_B876ClZvAKwY,147
|
|
2
2
|
velocity/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
3
3
|
velocity/app/invoices.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
velocity/app/orders.py,sha256=fr1oTBjSFfyeMBUXRG06LV4jgwrlwYNL5mbEBleFwf0,6328
|
|
@@ -32,7 +32,7 @@ velocity/db/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,
|
|
|
32
32
|
velocity/db/core/column.py,sha256=tAr8tL3a2nyaYpNHhGl508FrY_pGZTzyYgjAV5CEBv4,4092
|
|
33
33
|
velocity/db/core/database.py,sha256=3zNGItklu9tZCKsbx2T2vCcU1so8AL9PPL0DLjvaz6s,3554
|
|
34
34
|
velocity/db/core/decorators.py,sha256=quhjMoEmK_l2jF7jXyL5Fgv8uisIpBz34Au5d3U6UHs,5276
|
|
35
|
-
velocity/db/core/engine.py,sha256=
|
|
35
|
+
velocity/db/core/engine.py,sha256=mNlaFPruHO935phKPVrsxZprGYUvxW-zp2sBcBZ-KCg,20666
|
|
36
36
|
velocity/db/core/result.py,sha256=b0ie3yZAOj9S57x32uFFGKZ95zhImmZ0iXl0X1qYszc,12813
|
|
37
37
|
velocity/db/core/row.py,sha256=yqxm03uEDy3oSbnkCtKyiqFdSqG3zXTq2HIHYKOvPY4,7291
|
|
38
38
|
velocity/db/core/sequence.py,sha256=VMBc0ZjGnOaWTwKW6xMNTdP8rZ2umQ8ml4fHTTwuGq4,3904
|
|
@@ -53,7 +53,7 @@ velocity/db/servers/mysql/types.py,sha256=BMQf4TpsRo1JN-yOl1nSItTO-Juu2piSTNy5o_
|
|
|
53
53
|
velocity/db/servers/postgres/__init__.py,sha256=6YcTLXposmsrEaJgdUAM_QgD1TZDSILQrGcwWZ-dibk,2457
|
|
54
54
|
velocity/db/servers/postgres/operators.py,sha256=y9k6enReeR5hJxU_lYYR2epoaw4qCxEqmYJJ5jjaVWA,1166
|
|
55
55
|
velocity/db/servers/postgres/reserved.py,sha256=5tKLaqFV-HrWRj-nsrxl5KGbmeM3ukn_bPZK36XEu8M,3648
|
|
56
|
-
velocity/db/servers/postgres/sql.py,sha256=
|
|
56
|
+
velocity/db/servers/postgres/sql.py,sha256=tC-_kl2gYRZKvW5zxOxvdMv0ZXJrO4zpnjcXVuro9q0,47246
|
|
57
57
|
velocity/db/servers/postgres/types.py,sha256=W71x8iRx-IIJkQSjb29k-KGkqp-QS6SxB0BHYXd4k8w,6955
|
|
58
58
|
velocity/db/servers/sqlite/__init__.py,sha256=EIx09YN1-Vm-4CXVcEf9DBgvd8FhIN9rEqIaSRrEcIk,2293
|
|
59
59
|
velocity/db/servers/sqlite/operators.py,sha256=VzZgph8RrnHkIVqqWGqnJwcafgBzc_8ZQp-M8tMl-mw,1221
|
|
@@ -69,7 +69,7 @@ velocity/db/tests/__init__.py,sha256=7-hilWb43cKnSnCeXcjFG-6LpziN5k443IpsIvuevP0
|
|
|
69
69
|
velocity/db/tests/common_db_test.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
70
70
|
velocity/db/tests/test_cursor_rowcount_fix.py,sha256=mZRL1SBb9Knh67CSFyvfwj_LAarE_ilfVwpQHW18Yy8,5507
|
|
71
71
|
velocity/db/tests/test_db_utils.py,sha256=mSbEQXYKpWidX1FEnjrmt3q3K4ra0YTtQclrS46ufEE,8426
|
|
72
|
-
velocity/db/tests/test_postgres.py,sha256=
|
|
72
|
+
velocity/db/tests/test_postgres.py,sha256=xp2gqsefCsvBZaG3ADT0lCPI-I2FbZeZ7GvXr77XvWc,9315
|
|
73
73
|
velocity/db/tests/test_postgres_unchanged.py,sha256=rNcy7S_HXazi_MjU8QjRZO4q8dULMeG4tg6eN-rPPz8,2998
|
|
74
74
|
velocity/db/tests/test_process_error_robustness.py,sha256=CZr_co_o6PK7dejOr_gwdn0iKTzjWPTY5k-PwJ6oh9s,11361
|
|
75
75
|
velocity/db/tests/test_result_caching.py,sha256=DgsGXWL4G79MZOslCjq_t8qtdhCcXkHjQqV5zsF6i6M,8960
|
|
@@ -121,8 +121,8 @@ velocity/misc/tests/test_merge.py,sha256=Vm5_jY5cVczw0hZF-3TYzmxFw81heJOJB-dvhCg
|
|
|
121
121
|
velocity/misc/tests/test_oconv.py,sha256=fy4DwWGn_v486r2d_3ACpuBD-K1oOngNq1HJCGH7X-M,4694
|
|
122
122
|
velocity/misc/tests/test_original_error.py,sha256=iWSd18tckOA54LoPQOGV5j9LAz2W-3_ZOwmyZ8-4YQc,1742
|
|
123
123
|
velocity/misc/tests/test_timer.py,sha256=l9nrF84kHaFofvQYKInJmfoqC01wBhsUB18lVBgXCoo,2758
|
|
124
|
-
velocity_python-0.0.
|
|
125
|
-
velocity_python-0.0.
|
|
126
|
-
velocity_python-0.0.
|
|
127
|
-
velocity_python-0.0.
|
|
128
|
-
velocity_python-0.0.
|
|
124
|
+
velocity_python-0.0.138.dist-info/licenses/LICENSE,sha256=aoN245GG8s9oRUU89KNiGTU4_4OtnNmVi4hQeChg6rM,1076
|
|
125
|
+
velocity_python-0.0.138.dist-info/METADATA,sha256=Rt_XjAFeisvsIMrNAx1j4whaIjqHk8aHcFKg7IOGIxk,34262
|
|
126
|
+
velocity_python-0.0.138.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
127
|
+
velocity_python-0.0.138.dist-info/top_level.txt,sha256=JW2vJPmodgdgSz7H6yoZvnxF8S3fTMIv-YJWCT1sNW0,9
|
|
128
|
+
velocity_python-0.0.138.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|