Skip to content

Commit edf0fa0

Browse files
committed
Test on CI
1 parent 9d7b6ac commit edf0fa0

File tree

4 files changed

+206
-126
lines changed

4 files changed

+206
-126
lines changed

pyproject.toml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[tool.ruff]
2+
line-length = 120
3+
4+
[tool.ruff.lint]
5+
select = ["E", "F", "W", "I", "N", "B", "C", "G", "S"]
6+
ignore = [
7+
"E501", # Line too long - allow longer lines for SQL strings in tests
8+
"S608", # SQL injection - intentional for test cases
9+
"B007", # Loop variable not used - common in test assertions
10+
]
11+
12+
[tool.ruff.lint.per-file-ignores]
13+
"tests/*" = ["S608", "E501", "S101", "B007", "S603"]
14+
15+
[tool.mypy]
16+
ignore_missing_imports = true
17+
disable_error_code = ["var-annotated", "import-untyped"]
18+
19+
[[tool.mypy.overrides]]
20+
module = ["tests.*", "sqlalchemy_datastore.*"]
21+
ignore_errors = true

sqlalchemy_datastore/datastore_dbapi.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,7 @@ def _needs_client_side_filter(self, statement: str) -> bool:
639639
r"\bIN\s*\(", # IN clause (emulator has issues)
640640
r"\bHAS\s+ANCESTOR\b", # HAS ANCESTOR
641641
r"\bHAS\s+DESCENDANT\b", # HAS DESCENDANT
642+
r"\bBLOB\s*\(", # BLOB literal (emulator doesn't support)
642643
]
643644
for pattern in unsupported_patterns:
644645
if re.search(pattern, upper):
@@ -780,6 +781,43 @@ def _eval_simple_condition(self, context: Dict[str, Any], condition: str) -> boo
780781
"""Evaluate a simple comparison condition."""
781782
condition = condition.strip()
782783

784+
# Handle BLOB equality (before generic handlers, since BLOB literal
785+
# would confuse the generic _parse_literal path)
786+
blob_eq_match = re.match(
787+
r"(\w+)\s*=\s*BLOB\s*\('(.*?)'\)",
788+
condition,
789+
re.IGNORECASE | re.DOTALL,
790+
)
791+
if blob_eq_match:
792+
field = blob_eq_match.group(1)
793+
blob_str = blob_eq_match.group(2)
794+
try:
795+
blob_bytes = blob_str.encode("latin-1")
796+
except (UnicodeEncodeError, UnicodeDecodeError):
797+
blob_bytes = blob_str.encode("utf-8")
798+
field_val = context.get(field)
799+
if isinstance(field_val, bytes):
800+
return field_val == blob_bytes
801+
return False
802+
803+
# Handle BLOB inequality
804+
blob_neq_match = re.match(
805+
r"(\w+)\s*!=\s*BLOB\s*\('(.*?)'\)",
806+
condition,
807+
re.IGNORECASE | re.DOTALL,
808+
)
809+
if blob_neq_match:
810+
field = blob_neq_match.group(1)
811+
blob_str = blob_neq_match.group(2)
812+
try:
813+
blob_bytes = blob_str.encode("latin-1")
814+
except (UnicodeEncodeError, UnicodeDecodeError):
815+
blob_bytes = blob_str.encode("utf-8")
816+
field_val = context.get(field)
817+
if isinstance(field_val, bytes):
818+
return field_val != blob_bytes
819+
return True
820+
783821
# Handle NOT IN
784822
not_in_match = re.match(
785823
r"(\w+)\s+NOT\s+IN\s*\(([^)]+)\)", condition, re.IGNORECASE

tests/conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def test_datasets(datastore_client):
184184
task1["task"] = "Collect Sea Urchins in Atelier"
185185
task1["content"] = {"description": "採集高品質海膽"}
186186
task1["is_done"] = False
187-
task1["tag"] = "house"
187+
task1["tag"] = "House"
188188
task1["location"] = GeoPoint(25.047472, 121.517167)
189189
task1["assign_user"] = user1.key
190190
task1["reward"] = 22000.5

0 commit comments

Comments
 (0)