Commit 34bcf51f authored by jan.koester's avatar jan.koester
Browse files

test

parent 55b42a18
Loading
Loading
Loading
Loading
+9 −3
Changes for plugins/content/content.cpp: 9 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -1782,7 +1782,7 @@ namespace blogi {
            dbpp::DBResult res;
            sql << "CREATE TABLE IF NOT EXISTS content ("
                <<   "id integer PRIMARY KEY " << Args->database[0]->autoincrement(sql) << ","
                <<     "title character varying(255) NOT NULL,"
                <<     "title character varying(255) NOT NULL UNIQUE,"
                <<     "slug character varying(255) NOT NULL DEFAULT '',"
                <<     "text text NOT NULL,"
                <<     "descrition character varying(255) NOT NULL,"
@@ -1837,6 +1837,13 @@ namespace blogi {
                }
            } catch (...) {}

            // Migration: add UNIQUE constraint on title if missing
            try {
                sql.clear();
                sql << "ALTER TABLE content ADD CONSTRAINT content_title_unique UNIQUE (title);";
                Args->database[0]->exec(sql, res);
            } catch (...) { /* constraint already exists */ }

            return;
        }

@@ -2059,6 +2066,7 @@ namespace blogi {
                int dupCount = Args->database[tid]->exec(sql, res);

                int content_id = 0;
                std::string slug = makeSlug(title.c_str());

                if (dupCount > 0 && !overwrite) {
                    // Duplicate found — ask user to confirm overwrite
@@ -2071,7 +2079,6 @@ namespace blogi {
                    // Overwrite existing post
                    content_id = atoi(res[0][0]);
                    sql.clear();
                    std::string slug = makeSlug(title.c_str());
                    sql << "UPDATE content SET slug='" << dbpp::SQL::escaped(sbuf, slug.c_str())
                        << "', descrition='" << dbpp::SQL::escaped(sbuf, description.c_str())
                        << "', text='" << dbpp::SQL::escaped(sbuf, html.c_str())
@@ -2087,7 +2094,6 @@ namespace blogi {
                } else {
                    // New post
                    sql.clear();
                    std::string slug = makeSlug(title.c_str());
                    sql << "INSERT INTO content (title,slug,descrition,text,author,created) VALUES ('"
                        << dbpp::SQL::escaped(sbuf, title.c_str()) << "','"
                        << dbpp::SQL::escaped(sbuf, slug.c_str()) << "','"