diff --git a/SqlInsert.h b/SqlInsert.h index ea9a8ab..07c5918 100644 --- a/SqlInsert.h +++ b/SqlInsert.h @@ -46,7 +46,7 @@ struct ColumnValue Sql::warning, UsageOfClientSideTime>::print(); } - template + template ::type> ColumnValue(const ColumnT&) : columnName(ColumnT::sqlName()), isDefault(true) { @@ -60,6 +60,9 @@ struct ColumnValue QString columnName; QVariant value; bool isDefault; + + /// @internal needed for InsertExpr's vector + ColumnValue() : isDefault(true) {} }; // TODO find out if it would be possible to have an operator= instead @@ -108,7 +111,7 @@ struct InsertExpr */ InsertExpr columns( const QList& cols ) { - values += cols; + values += cols.toVector(); return *this; } InsertExpr columns( const ColumnValue& col ) diff --git a/tests/inserttest.cpp b/tests/inserttest.cpp index bbb6be7..258b9dd 100644 --- a/tests/inserttest.cpp +++ b/tests/inserttest.cpp @@ -57,6 +57,14 @@ private Q_SLOTS: .queryBuilder() << "INSERT INTO tblPerson (PersonForename,PersonSurname) VALUES (:0,DEFAULT)" << (QVector() << QLatin1String( "Ford" )); + + QTest::newRow( "two col, bool and datetime" ) + << insert() + .into( Person ) + .columns( Person.HireRights << false & Person.Hired << QDateTime(QDate(2013, 1, 1)) ) + .queryBuilder() + << "INSERT INTO tblPerson (HireRights,Hired) VALUES (:0,:1)" + << (QVector() << false << QDateTime(QDate(2013, 1, 1))); } void testInsert()