Support 64bit primary keys

Primary keys in SQLite are 64bit in size. We, however, used the int
datatype which often is 32bit only. Also the conversion from QString and
other Qt datatypes to numbers was done by the toInt() method which fails
on these large numbers. These issues are fixed by this commit, adding
support for databases with big primary key values.

See issue #172.
This commit is contained in:
Martin Kleusberg
2015-02-04 17:55:43 +01:00
parent f63b11925d
commit c20c58595a
3 changed files with 14 additions and 14 deletions

View File

@@ -66,7 +66,7 @@ public:
* @param rowdata A list of QByteArray containing the row data.
* @return true if statement execution was ok, else false.
*/
bool getRow(const QString& sTableName, int rowid, QList<QByteArray>& rowdata);
bool getRow(const QString& sTableName, long rowid, QList<QByteArray>& rowdata);
/**
* @brief max Queries the table t for the max value of field.
@@ -77,16 +77,16 @@ public:
int64_t max(const sqlb::Table& t, sqlb::FieldPtr field) const;
void updateSchema();
int addRecord(const QString& sTableName);
long addRecord(const QString& sTableName);
/**
* @brief Creates an empty insert statement.
* @param pk_value This optional parameter can be used to manually set a specific value for the primary key column
* @return An sqlite conform INSERT INTO statement with empty values. (NULL,'',0)
*/
QString emptyInsertStmt(const sqlb::Table& t, int pk_value = -1) const;
bool deleteRecord(const QString& table, int rowid);
bool updateRecord(const QString& table, const QString& column, int row, const QByteArray& value);
QString emptyInsertStmt(const sqlb::Table& t, long pk_value = -1) const;
bool deleteRecord(const QString& table, long rowid);
bool updateRecord(const QString& table, const QString& column, long row, const QByteArray& value);
bool createTable(const QString& name, const sqlb::FieldVector& structure);
bool renameTable(const QString& from_table, const QString& to_table);