Skip to content

Commit

Permalink
Fix ci UT: check the beginning of connection string to determine whet…
Browse files Browse the repository at this point in the history
…her it's postgres or not

Signed-off-by: Tony Chou <tcheon8788@gmail.com>
  • Loading branch information
chonyy committed Jul 12, 2022
1 parent f3af8b3 commit b37637d
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

from pyhocon import ConfigFactory, ConfigTree
from pytz import UTC
from sqlalchemy.engine.url import make_url

from databuilder import Scoped
from databuilder.extractor.base_extractor import Extractor
Expand Down Expand Up @@ -175,8 +174,8 @@ def _get_partitioned_table_sql_alchemy_extractor(self) -> Extractor:
return sql_alchemy_extractor

def _choose_default_partitioned_sql_stm(self) -> str:
url = make_url(self._conf.get_string("extractor.sqlalchemy.conn_string"))
if url.drivername.lower() in ['postgresql', 'postgres']:
conn_string = self._conf.get_string("extractor.sqlalchemy.conn_string")
if conn_string.startswith('postgres') or conn_string.startswith('postgresql'):
return self.DEFAULT_POSTGRES_PARTITION_TABLE_SQL_STATEMENT
else:
return self.DEFAULT_PARTITION_TABLE_SQL_STATEMENT
Expand Down Expand Up @@ -213,8 +212,8 @@ def _get_non_partitioned_table_sql_alchemy_extractor(self) -> Extractor:
return sql_alchemy_extractor

def _choose_default_non_partitioned_sql_stm(self) -> List[str]:
url = make_url(self._conf.get_string("extractor.sqlalchemy.conn_string"))
if url.drivername.lower() in ['postgresql', 'postgres']:
conn_string = self._conf.get_string("extractor.sqlalchemy.conn_string")
if conn_string.startswith('postgres') or conn_string.startswith('postgresql'):
return [self.DEFAULT_POSTGRES_NON_PARTITIONED_TABLE_SQL_STATEMENT, self.DEFAULT_POSTGRES_ADDTIONAL_WHERE_CLAUSE]
else:
return [self.DEFAULT_NON_PARTITIONED_TABLE_SQL_STATEMENT, self.DEFAULT_ADDTIONAL_WHERE_CLAUSE]
Expand Down

0 comments on commit b37637d

Please sign in to comment.