sql: use _rowid_ instead of rowid

This doesn't really solve the problem, but reduces the chance
to have a nameclash with rowid, until we come up with something better
we can't fully support tables with a column name _rowid_ but that should
be very seldom
This commit is contained in:
Peinthor Rene
2014-08-22 23:21:44 +02:00
parent 3b907df8e3
commit 55678bb945
4 changed files with 6 additions and 6 deletions

View File

@@ -232,7 +232,7 @@ void EditTableDialog::itemChanged(QTreeWidgetItem *item, int column)
// we need to check for this case and cancel here. Maybe we can think of some way to modify the INSERT INTO ... SELECT statement
// to at least replace all troublesome NULL values by the default value
SqliteTableModel m(this, pdb);
m.setQuery(QString("SELECT COUNT(rowid) FROM `%1` WHERE `%2` IS NULL;").arg(curTable).arg(field->name()));
m.setQuery(QString("SELECT COUNT(_rowid_) FROM `%1` WHERE `%2` IS NULL;").arg(curTable).arg(field->name()));
if(m.data(m.index(0, 0)).toInt() > 0)
{
// There is a NULL value, so print an error message, uncheck the combobox, and return here

View File

@@ -436,7 +436,7 @@ bool DBBrowserDB::executeMultiSQL(const QString& statement, bool dirty, bool log
bool DBBrowserDB::getRow(const QString& sTableName, int rowid, QList<QByteArray>& rowdata)
{
QString sQuery = QString("SELECT * from %1 WHERE rowid=%2;").arg(sTableName).arg(rowid);
QString sQuery = QString("SELECT * from %1 WHERE _rowid_=%2;").arg(sTableName).arg(rowid);
QByteArray utf8Query = sQuery.toUtf8();
sqlite3_stmt *stmt;
bool ret = false;
@@ -488,7 +488,7 @@ bool DBBrowserDB::deleteRecord(const QString& table, int rowid)
bool ok = false;
lastErrorMessage = QString("no error");
QString statement = QString("DELETE FROM `%1` WHERE rowid=%2;").arg(table).arg(rowid);
QString statement = QString("DELETE FROM `%1` WHERE _rowid_=%2;").arg(table).arg(rowid);
if (_db){
logSQL(statement, kLogMsg_App);
@@ -510,7 +510,7 @@ bool DBBrowserDB::updateRecord(const QString& table, const QString& column, int
lastErrorMessage = QString("no error");
QString sql = QString("UPDATE `%1` SET `%2`=? WHERE rowid=%3;").arg(table).arg(column).arg(row);
QString sql = QString("UPDATE `%1` SET `%2`=? WHERE _rowid_=%3;").arg(table).arg(column).arg(row);
logSQL(sql, kLogMsg_App);
setRestorePoint();

View File

@@ -57,7 +57,7 @@ bool Field::isInteger() const
void Table::clear()
{
m_fields.clear();
m_rowidColumn = "rowid";
m_rowidColumn = "_rowid_";
}
Table::~Table()

View File

@@ -72,7 +72,7 @@ typedef QVector< FieldPtr > FieldVector;
class Table
{
public:
Table(const QString& name): m_name(name), m_rowidColumn("rowid") {}
Table(const QString& name): m_name(name), m_rowidColumn("_rowid_") {}
virtual ~Table();
void setName(const QString& name) { m_name = name; }