Skip to content

Commit

Permalink
Merge pull request #349 from datayoga-io/348-relationalwrite-db2-merg…
Browse files Browse the repository at this point in the history
…e-command-fails-when-the-column-names-are-in-uppercase

`relational.write` - case sensitivity issue for column matching
  • Loading branch information
spicy-sauce authored Nov 29, 2023
2 parents a34a348 + 4ee851b commit 56b331d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
5 changes: 4 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,5 +68,8 @@
"xack",
"xadd",
"zadd"
]
],
"python.testing.pytestArgs": ["."],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true
}
12 changes: 8 additions & 4 deletions core/src/datayoga_core/blocks/relational/write/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,17 @@ def setup_engine(self):
if x not in self.business_key_columns]

for column in self.columns:
if column not in self.tbl.columns:
if not any(col.name.lower() == column.lower() for col in self.tbl.columns):
raise ValueError(f"{column} column does not exist in {self.tbl.fullname} table")

self.delete_stmt = self.tbl.delete().where(
sa.and_(
*[(self.tbl.columns[column] == sa.bindparam(column)) for column in self.business_key_columns]))
conditions = []
for business_key_column in self.business_key_columns:
for tbl_column in self.tbl.columns:
if tbl_column.name.lower() == business_key_column.lower():
conditions.append(tbl_column == sa.bindparam(business_key_column))
break

self.delete_stmt = self.tbl.delete().where(sa.and_(*conditions))
self.upsert_stmt = self.generate_upsert_stmt()

except OperationalError as e:
Expand Down
4 changes: 2 additions & 2 deletions integration-tests/resources/jobs/tests/redis_to_db2.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ steps:
table: emp
opcode_field: __$$opcode
keys:
- id: _id
- ID: _id
mapping:
- full_name
- FULL_NAME: full_name
- country
- gender
- uses: relational.write
Expand Down

0 comments on commit 56b331d

Please sign in to comment.