compatibility with out-of-date sqlite: use '(1=0)' instead of 'false'

This commit is contained in:
Shish 2020-10-26 22:33:11 +00:00
parent e6e9d6db1c
commit 55e3cb5d63
11 changed files with 23 additions and 23 deletions

View File

@ -374,7 +374,7 @@ class Database
$this->execute("UPDATE $table SET $column = ($column IN ('Y', 1))"); $this->execute("UPDATE $table SET $column = ($column IN ('Y', 1))");
} }
if ($d == DatabaseDriver::PGSQL) { if ($d == DatabaseDriver::PGSQL) {
$this->execute("ALTER TABLE $table ADD COLUMN ${column}_b BOOLEAN DEFAULT FALSE NOT NULL"); $this->execute("ALTER TABLE $table ADD COLUMN ${column}_b BOOLEAN DEFAULT (1=0) NOT NULL");
$this->execute("UPDATE $table SET ${column}_b = ($column = 'Y')"); $this->execute("UPDATE $table SET ${column}_b = ($column = 'Y')");
$this->execute("ALTER TABLE $table DROP COLUMN $column"); $this->execute("ALTER TABLE $table DROP COLUMN $column");
$this->execute("ALTER TABLE $table RENAME COLUMN ${column}_b TO $column"); $this->execute("ALTER TABLE $table RENAME COLUMN ${column}_b TO $column");

View File

@ -456,11 +456,11 @@ class Image
"id" => $this->id, "id" => $this->id,
"width" => $this->width ?? 0, "width" => $this->width ?? 0,
"height" => $this->height ?? 0, "height" => $this->height ?? 0,
"lossless" => $database->scoresql_value_prepare($this->lossless), "lossless" => $this->lossless,
"video" => $database->scoresql_value_prepare($this->video), "video" => $this->video,
"video_codec" => $database->scoresql_value_prepare($this->video_codec), "video_codec" => $this->video_codec,
"image" => $database->scoresql_value_prepare($this->image), "image" => $this->image,
"audio" => $database->scoresql_value_prepare($this->audio), "audio" => $this->audio,
"length" => $this->length "length" => $this->length
] ]
); );

View File

@ -22,7 +22,7 @@ class Blotter extends Extension
id SCORE_AIPK, id SCORE_AIPK,
entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, entry_date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
entry_text TEXT NOT NULL, entry_text TEXT NOT NULL,
important BOOLEAN NOT NULL DEFAULT FALSE important BOOLEAN NOT NULL DEFAULT (1=0)
"); ");
// Insert sample data: // Insert sample data:
$database->execute( $database->execute(

View File

@ -21,7 +21,7 @@ class Forum extends Extension
if ($config->get_int("forum_version") < 1) { if ($config->get_int("forum_version") < 1) {
$database->create_table("forum_threads", " $database->create_table("forum_threads", "
id SCORE_AIPK, id SCORE_AIPK,
sticky BOOLEAN NOT NULL DEFAULT FALSE, sticky BOOLEAN NOT NULL DEFAULT (1=0),
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

View File

@ -74,7 +74,7 @@ class PrivMsg extends Extension
sent_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, sent_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
subject VARCHAR(64) NOT NULL, subject VARCHAR(64) NOT NULL,
message TEXT NOT NULL, message TEXT NOT NULL,
is_read BOOLEAN NOT NULL DEFAULT FALSE, is_read BOOLEAN NOT NULL DEFAULT (1=0),
FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE, FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE,
FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE
"); ");

View File

@ -132,7 +132,7 @@ class Pools extends Extension
$database->create_table("pools", " $database->create_table("pools", "
id SCORE_AIPK, id SCORE_AIPK,
user_id INTEGER NOT NULL, user_id INTEGER NOT NULL,
public BOOLEAN NOT NULL DEFAULT FALSE, public BOOLEAN NOT NULL DEFAULT (1=0),
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
description TEXT, description TEXT,
date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,

View File

@ -133,13 +133,13 @@ class PrivateImage extends Extension
if ($show_private) { if ($show_private) {
$event->add_querylet( $event->add_querylet(
new Querylet( new Querylet(
"private != :true OR owner_id = :private_owner_id", "private = :false OR owner_id = :private_owner_id",
["private_owner_id"=>$user->id, "true"=>true] ["private_owner_id"=>$user->id, "false"=>false]
) )
); );
} else { } else {
$event->add_querylet( $event->add_querylet(
new Querylet("private != :true", ["true"=>true]) new Querylet("private = :false", ["false"=>false])
); );
} }
} }
@ -153,8 +153,8 @@ class PrivateImage extends Extension
$query = ""; $query = "";
switch ($matches[1]) { switch ($matches[1]) {
case "no": case "no":
$query .= "private != :true"; $query .= "private = :false";
$params["true"] = true; $params["false"] = false;
break; break;
case "yes": case "yes":
$query .= "private = :true"; $query .= "private = :true";
@ -168,8 +168,8 @@ class PrivateImage extends Extension
} }
break; break;
case "any": case "any":
$query .= "private != :true OR owner_id = :private_owner_id"; $query .= "private = :false OR owner_id = :private_owner_id";
$params["true"] = true; $params["false"] = false;
$params["private_owner_id"] = $user->id; $params["private_owner_id"] = $user->id;
break; break;
} }
@ -280,7 +280,7 @@ class PrivateImage extends Extension
global $database; global $database;
if ($this->get_version(PrivateImageConfig::VERSION) < 1) { if ($this->get_version(PrivateImageConfig::VERSION) < 1) {
$database->execute("ALTER TABLE images ADD COLUMN private BOOLEAN NOT NULL DEFAULT FALSE"); $database->execute("ALTER TABLE images ADD COLUMN private BOOLEAN NOT NULL DEFAULT (1=0)");
$database->execute("CREATE INDEX images_private_idx ON images(private)"); $database->execute("CREATE INDEX images_private_idx ON images(private)");
$this->set_version(PrivateImageConfig::VERSION, 2); $this->set_version(PrivateImageConfig::VERSION, 2);
} }

View File

@ -33,7 +33,7 @@ class Relationships extends Extension
if ($this->get_version("ext_relationships_version") < 1) { if ($this->get_version("ext_relationships_version") < 1) {
$database->execute("ALTER TABLE images ADD parent_id INT"); $database->execute("ALTER TABLE images ADD parent_id INT");
$database->execute("ALTER TABLE images ADD has_children BOOLEAN DEFAULT FALSE NOT NULL"); $database->execute("ALTER TABLE images ADD has_children BOOLEAN DEFAULT (1=0) NOT NULL");
$database->execute("CREATE INDEX images__parent_id ON images(parent_id)"); $database->execute("CREATE INDEX images__parent_id ON images(parent_id)");
$database->execute("CREATE INDEX images__has_children ON images(has_children)"); $database->execute("CREATE INDEX images__has_children ON images(has_children)");
$this->set_version("ext_relationships_version", 3); $this->set_version("ext_relationships_version", 3);

View File

@ -36,7 +36,7 @@ class Tips extends Extension
if ($this->get_version("ext_tips_version") < 1) { if ($this->get_version("ext_tips_version") < 1) {
$database->create_table("tips", " $database->create_table("tips", "
id SCORE_AIPK, id SCORE_AIPK,
enable BOOLEAN NOT NULL DEFAULT FALSE, enable BOOLEAN NOT NULL DEFAULT (1=0),
image TEXT NOT NULL, image TEXT NOT NULL,
text TEXT NOT NULL, text TEXT NOT NULL,
"); ");

View File

@ -97,7 +97,7 @@ class Trash extends Extension
$matches = []; $matches = [];
if (is_null($event->term) && $this->no_trash_query($event->context)) { if (is_null($event->term) && $this->no_trash_query($event->context)) {
$event->add_querylet(new Querylet("trash != :true", ["true"=>true])); $event->add_querylet(new Querylet("trash = :false", ["false"=>false]));
} }
if (is_null($event->term)) { if (is_null($event->term)) {
@ -182,7 +182,7 @@ class Trash extends Extension
global $database; global $database;
if ($this->get_version(TrashConfig::VERSION) < 1) { if ($this->get_version(TrashConfig::VERSION) < 1) {
$database->execute("ALTER TABLE images ADD COLUMN trash BOOLEAN NOT NULL DEFAULT FALSE"); $database->execute("ALTER TABLE images ADD COLUMN trash BOOLEAN NOT NULL DEFAULT (1=0)");
$database->execute("CREATE INDEX images_trash_idx ON images(trash)"); $database->execute("CREATE INDEX images_trash_idx ON images(trash)");
$this->set_version(TrashConfig::VERSION, 2); $this->set_version(TrashConfig::VERSION, 2);
} }

View File

@ -133,7 +133,7 @@ class Wiki extends Extension
date TIMESTAMP DEFAULT CURRENT_TIMESTAMP, date TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
title VARCHAR(255) NOT NULL, title VARCHAR(255) NOT NULL,
revision INTEGER NOT NULL DEFAULT 1, revision INTEGER NOT NULL DEFAULT 1,
locked BOOLEAN NOT NULL DEFAULT FALSE, locked BOOLEAN NOT NULL DEFAULT (1=0),
body TEXT NOT NULL, body TEXT NOT NULL,
UNIQUE (title, revision), UNIQUE (title, revision),
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT