EditTableDialog: Fix handling of default values

Fix the handling of default values in the Edit Table dialog by doing two
things: First, change the sqlb::Field class so that it doesn't put quotes
around any default values no matter what. This breaks for example NULL
default values but also causes invalid syntax if the default value is
already in quotes. Secondly, change the Edit Table dialog itself to
double check if the user should've put quotes around their default value
but hasn't. In this case add them automatically.

See issues #64 and #126.
This commit is contained in:
Martin Kleusberg
2014-10-15 12:45:43 +02:00
parent dea0a65385
commit c29702a1b9
2 changed files with 24 additions and 2 deletions

View File

@@ -15,7 +15,7 @@ QString Field::toString(const QString& indent, const QString& sep) const
if(m_notnull)
str += " NOT NULL";
if(!m_defaultvalue.isEmpty())
str += QString(" DEFAULT '%1'").arg(m_defaultvalue);
str += QString(" DEFAULT %1").arg(m_defaultvalue);
if(!m_check.isEmpty())
str += " CHECK(" + m_check + ")";
if(m_autoincrement)