Skip to content

Commit

Permalink
Check if test goes green.
Browse files Browse the repository at this point in the history
  • Loading branch information
recipe committed Feb 19, 2024
1 parent fd4b98d commit 752e3a2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
14 changes: 9 additions & 5 deletions append_version.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,17 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <https://www.gnu.org/licenses/>.

DELIMITER //

CREATE TABLE IF NOT EXISTS versions (
id INT UNSIGNED AUTO_INCREMENT PRIMARY KEY,
version VARCHAR(64) COLLATE utf8mb4_bin NOT NULL,
sort_order BIGINT UNSIGNED NOT NULL,
UNIQUE KEY unique_version (version),
KEY idx_sort_order_version (sort_order, version)
) ENGINE = InnoDB charset utf8mb4;
) ENGINE = InnoDB charset utf8mb4 //

DROP FUNCTION IF EXISTS `GET_SORT_ORDER`;
DROP FUNCTION IF EXISTS `GET_SORT_ORDER` //

CREATE FUNCTION GET_SORT_ORDER(version VARCHAR(255)) RETURNS BIGINT UNSIGNED
NOT DETERMINISTIC
Expand Down Expand Up @@ -80,9 +82,9 @@ BEGIN
END IF;

RETURN l + FLOOR((r - l) / 2);
END;
END //

DROP TRIGGER IF EXISTS bi_versions_set_sort_order;
DROP TRIGGER IF EXISTS bi_versions_set_sort_order //

CREATE TRIGGER bi_versions_set_sort_order BEFORE INSERT ON versions
FOR EACH ROW
Expand All @@ -96,4 +98,6 @@ BEGIN
END IF;
SET NEW.sort_order = v;
END IF;
END;
END //

DELIMITER ;
2 changes: 1 addition & 1 deletion tests.sql
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,6 @@ VALUES
ROW('1 < 1.0.1-beta', VERSION_COMPARE('1', '1.0.1-beta') = -1),
ROW('alpha < 1.0.0', VERSION_COMPARE('alpha', '1.0.0') = -1),
ROW('alpha < beta', VERSION_COMPARE('alpha', 'beta') = -1),
ROW('4.9.4+xy1 < 4.9.4', VERSION_COMPARE('4.9.4+xy1', '4.9.4') = 0)
ROW('4.9.4+xy1 < 4.9.4', VERSION_COMPARE('4.9.4+xy1', '4.9.4') = -1)
) AS t
WHERE t.`column_1` <> 1;

0 comments on commit 752e3a2

Please sign in to comment.