jwcook23 / mssql_dataframe

Update, Upsert, and Merge from Python dataframes to SQL Server and Azure SQL database.
MIT License
11 stars 4 forks source link

where statement incorrect syntax near 'OR' #13

Closed jwcook23 closed 2 years ago

jwcook23 commented 2 years ago

Within read.table, dynamic.where produces the following syntax:

where = "ColumnA IS NULL OR ColumnA != 'CLOSED'"
where_statement, where_args = dynamic.where(self._connection.cursor(), where)

where_statement -> 'WHERE [ColumnA] != ? OR'
where_args -> ['CLOSED']
jwcook23 commented 2 years ago

Issue caused by ColumnA appearing twice in the where statement. The following works correctly:

 where = "ColumnA IS NULL OR ColumnB != 'CLOSED'"
 where_statement, where_args = dynamic.where(cursor, where)

where_statement -> 'WHERE [ColumnA] IS NULL OR [ColumnB] != ?'
where_args -> ['CLOSED']