From 19d85e415d2b1d21f5af9b0326cf246b54b22fdf Mon Sep 17 00:00:00 2001 From: Shish Date: Mon, 26 Oct 2020 18:55:03 +0000 Subject: [PATCH] booleanise relationships --- ext/relationships/main.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ext/relationships/main.php b/ext/relationships/main.php index de1bf7a5..87bf0fa3 100644 --- a/ext/relationships/main.php +++ b/ext/relationships/main.php @@ -31,19 +31,20 @@ class Relationships extends Extension { global $database; - // Create the database tables if ($this->get_version("ext_relationships_version") < 1) { $database->execute("ALTER TABLE images ADD parent_id INT"); - $database->execute($database->scoreql_to_sql("ALTER TABLE images ADD has_children SCORE_BOOL DEFAULT SCORE_BOOL_N NOT NULL")); + $database->execute("ALTER TABLE images ADD has_children BOOLEAN DEFAULT FALSE NOT NULL"); $database->execute("CREATE INDEX images__parent_id ON images(parent_id)"); - $this->set_version("ext_relationships_version", 1); } if ($this->get_version("ext_relationships_version") < 2) { $database->execute("CREATE INDEX images__has_children ON images(has_children)"); - $this->set_version("ext_relationships_version", 2); } + if ($this->get_version("ext_relationships_version") < 3) { + $database->standardise_boolean("images", "has_children"); + $this->set_version("ext_relationships_version", 3); + } } public function onImageInfoSet(ImageInfoSetEvent $event) @@ -204,9 +205,8 @@ class Relationships extends Extension ["pid"=>$parent_id] ); $database->execute( - "UPDATE images - SET has_children = :has_children WHERE id = :pid", - ["has_children"=>$database->scoresql_value_prepare($children>0), "pid"=>$parent_id] + "UPDATE images SET has_children = :has_children WHERE id = :pid", + ["has_children"=>$children>0, "pid"=>$parent_id] ); } }