Skip to content

Commit

Permalink
feat(open-mysql-db): remove null
Browse files Browse the repository at this point in the history
  • Loading branch information
yangwucheng committed Apr 12, 2024
1 parent 50972bf commit e55449a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
6 changes: 5 additions & 1 deletion extensions/open-mysql-db/python-testcases/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
data = {'id': [1, 2, 3],
'name': ['Alice', 'Bob', 'Charlie'],
'age': [25, 30, 35],
'score': [1.1, 2.2, 3.3]
'score': [1.1, 2.2, 3.3],
'ts': [pd.Timestamp.utcnow().timestamp(), pd.Timestamp.utcnow().timestamp(),
pd.Timestamp.utcnow().timestamp()],
'dt': [pd.to_datetime('20240101', format='%Y%m%d'), pd.to_datetime('20240201', format='%Y%m%d'),
pd.to_datetime('20240301', format='%Y%m%d')],
}
df = pd.DataFrame(data)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,12 @@ public void query(
}
} else if (sql.matches("(?i)(?s)^\\s*CREATE TABLE.*$")) {
// convert data type TEXT to STRING
sql = sql.replaceAll(" TEXT", " STRING");
sql = sql.replaceAll("(?i) TEXT", " STRING");
// sql = sql.replaceAll("(?i) DATETIME", " DATE");
if (!sql.toLowerCase().contains(" not null")
&& sql.toLowerCase().contains(" null")) {
sql = sql.replaceAll("(?i) null", "");
}
} else {
Matcher crateDatabaseMatcher = createDatabasePattern.matcher(sql);
Matcher selectLimitMatcher = selectLimitPattern.matcher(sql);
Expand Down

0 comments on commit e55449a

Please sign in to comment.