Commit a087d5b8 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Fix table creation syntax

parent 92654cf7
......@@ -14,11 +14,6 @@ Album::Album(sqlite3* dbConnection, sqlite3_stmt* stmt)
m_lastSyncDate = sqlite3_column_int( stmt, 6 );
}
Album::Album(sqlite3* dbConnection)
{
}
const std::string& Album::name()
{
return m_name;
......@@ -54,12 +49,16 @@ const std::vector<IAlbumTrack*>&Album::tracks()
return *m_tracks;
}
bool Album::createTable(sqlite3* dbConnection)
bool Album::createTable( sqlite3* dbConnection )
{
const char* req = "CREATE TABLE IF NOT EXISTS Album("
"id_album INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT, UNSIGNED INTEGER release_year, TEXT short_summary,"
"TEXT artwork_url, UNSIGNED INTEGER last_sync_date)";
"id_album INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT,"
"release_year UNSIGNED INTEGER,"
"short_summary TEXT,"
"artwork_url TEXT,"
"UNSIGNED INTEGER last_sync_date"
")";
return SqliteTools::createTable( dbConnection, req );
}
......
......@@ -9,7 +9,6 @@ class Album : public IAlbum
{
public:
Album( sqlite3* dbConnection, sqlite3_stmt* stmt );
Album( sqlite3* dbConnection );
virtual const std::string& name();
virtual unsigned int releaseYear();
......
......@@ -16,7 +16,7 @@ AlbumTrack::AlbumTrack( sqlite3* dbConnection, sqlite3_stmt* stmt )
bool AlbumTrack::createTable(sqlite3* dbConnection)
{
const char* req = "CREATE TABLE IF NOT EXISTS AlbumTrack ("
"id_track INTEGER PRIMARY KEY AUTO INCREMENT,"
"id_track INTEGER PRIMARY KEY AUTOINCREMENT,"
"title TEXT,"
"genre TEXT,"
"track_number UNSIGNED INTEGER,"
......
......@@ -31,10 +31,10 @@ std::vector<IFile*> Label::files()
bool Label::createTable(sqlite3* dbConnection)
{
const char* req = "CREATE TABLE IF NOT EXISTS Label("
"id_label INTEGER PRIMARY KEY AUTO INCREMENT, "
"id_label INTEGER PRIMARY KEY AUTOINCREMENT, "
"name TEXT"
")";
if ( SqliteTools::createTable( dbConnection, req ) )
if ( SqliteTools::createTable( dbConnection, req ) == false )
return false;
req = "CREATE TABLE IF NOT EXISTS LabelFileRelation("
"id_label INTEGER,"
......
......@@ -53,8 +53,11 @@ const std::string& Show::tvdbId()
bool Show::createTable(sqlite3* dbConnection)
{
const char* req = "CREATE TABLE IF NOT EXISTS Show("
"id_show INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT, UNSIGNED INTEGER release_year, TEXT short_summary,"
"TEXT artwork_url, UNSIGNED INTEGER last_sync_date, TEXT tvdb_id)";
"id_show INTEGER PRIMARY KEY AUTOINCREMENT,"
"name TEXT, UNSIGNED INTEGER release_year, TEXT short_summary,"
"artwork_url TEXT,"
"last_sync_date UNSIGNED INTEGER,"
"tvdb_id TEXT"
")";
return SqliteTools::createTable( dbConnection, req );
}
......@@ -15,5 +15,10 @@ bool SqliteTools::createTable( sqlite3 *db, const char* request )
res = sqlite3_step( stmt );
while ( res != SQLITE_DONE && res != SQLITE_ERROR )
res = sqlite3_step( stmt );
if ( res == SQLITE_ERROR )
{
std::cerr << "Failed to execute request: " << request << std::endl;
std::cerr << sqlite3_errmsg( db ) << std::endl;
}
return res == SQLITE_DONE;
}
Markdown is supported
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