Commit f7a4324d authored by npedot's avatar npedot
Browse files

adds if not exists to sql create table

parent 6c223d51
...@@ -69,10 +69,12 @@ class SQLizeCreateUseCase { ...@@ -69,10 +69,12 @@ class SQLizeCreateUseCase {
private fun createTableCommand(createTable: CreateTable): String { private fun createTableCommand(createTable: CreateTable): String {
var cols = " " var cols = " "
for (col in createTable.columns) { for (col in createTable.columns) {
cols+="${col.name} ${col.dbtype} ," var colType = col.dbtype
if (colType == null || colType.trim().isEmpty()) colType = "varchar(64)"
cols+="${col.name} ${colType} ,"
} }
cols = cols.dropLast(2) cols = cols.dropLast(2)
return "CREATE TABLE ${createTable.name} ($cols);" return "CREATE TABLE IF NOT EXISTS ${createTable.name} ($cols);"
} }
private fun createViewCommand(createView: CreateView):String { private fun createViewCommand(createView: CreateView):String {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment