Skip to content

Commit

Permalink
Releasing version 1.0 of MyTAP
Browse files Browse the repository at this point in the history
  • Loading branch information
Helma van der Linden committed Jul 21, 2018
1 parent f0ca466 commit e21844d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 33 deletions.
7 changes: 7 additions & 0 deletions Changes
@@ -1,6 +1,13 @@
Revision history for MyTAP
==========================

1.0 2018-07-21
-------------------------
This is a massive rewrite and extension of the available tests with thanks to @animalcarpet.
This version also has version specific tests and uses slightly different tests based
on the MySQL version.
This version is tested on MySQL 5.5, 5.6 and 5.7

0.07 2018-06-18
-------------------------
* col_has_unique_index, col_hasnt_unique_index added to test for
Expand Down
2 changes: 1 addition & 1 deletion README.md
@@ -1,4 +1,4 @@
MyTAP 0.07
MyTAP 1.0
==========

MyTAP is a unit testing framework for MySQL 5.x written using fuctions and
Expand Down
3 changes: 3 additions & 0 deletions docs/_data/releases.yml
Expand Up @@ -18,3 +18,6 @@

- version: 0.07
date: 2018-06-18

- version: 1.0
date: 2018-07-21
64 changes: 32 additions & 32 deletions mytap.sql
Expand Up @@ -30,7 +30,7 @@ DROP FUNCTION IF EXISTS mytap_version //
CREATE FUNCTION mytap_version()
RETURNS VARCHAR(10)
BEGIN
RETURN '0.07';
RETURN '1.0';
END //

DROP FUNCTION IF EXISTS mysql_version //
Expand Down Expand Up @@ -510,19 +510,19 @@ END //
DROP FUNCTION IF EXISTS quote_ident //
CREATE FUNCTION quote_ident(ident TEXT) RETURNS TEXT
BEGIN
IF ISNULL(ident) THEN
IF ISNULL(ident) THEN
RETURN 'NULL';
END IF;

IF ident = '' THEN
RETURN '\'\'';
END IF;

IF LOCATE('ANSI_QUOTES', @@SQL_MODE) > 0 THEN
IF is_reserved(ident) OR locate('"', ident) > 0 THEN
RETURN concat('"', replace(ident, '"', '""'), '"');
END IF;
ELSE
ELSE
IF is_reserved(ident) OR locate('`', ident) > 0 THEN
RETURN concat('`', replace(ident, '`', '``'), '`');
END IF;
Expand All @@ -535,27 +535,27 @@ END //

-- Just do it
-- I wish people wouldn't choose identifiers that need quoting,
-- but they do, and often just because they can. MySQL has no
-- array type (yet), which would make a lot of this simpler, so
-- but they do, and often just because they can. MySQL has no
-- array type (yet), which would make a lot of this simpler, so
-- we have to lay down some rules about how identifiers
-- can be presented for tests. In the end this boils down to:

-- lists must have all elements quoted
-- and
-- there can't be any spaces between elements because they are
-- legal characters in a quoted identifier.
-- lists must have all elements quoted
-- and
-- there can't be any spaces between elements because they are
-- legal characters in a quoted identifier.

-- In addition, all identifiers need be presented in a
-- In addition, all identifiers need be presented in a
-- consistent manner because the lack of function overloading means
-- you can't have similarly named functions to deal with multi-valued
-- identifier checks and scalar value ones. This, in turn, means
-- that scalars that wouldn't normally need quoting need to be and
-- that the quoting method needs to be consistent.

DROP FUNCTION IF EXISTS qi //
CREATE FUNCTION qi(ident TEXT) RETURNS TEXT
BEGIN
-- It's quoted already return it
-- It's quoted already return it
-- replace ANSI quotes with backticks
-- add backticks to everything else
-- This won't work for people who use quotes within identifiers
Expand All @@ -564,11 +564,11 @@ BEGIN
IF LEFT(ident,1) = '`' AND RIGHT(ident,1) = '`' THEN
RETURN ident;
END IF;

IF LEFT(ident,1) = '"' AND RIGHT(ident,1) = '"' THEN
RETURN CONCAT('`', TRIM(BOTH '"' FROM ident) ,'`');
END IF;

RETURN CONCAT('`', ident, '`');
END //

Expand All @@ -581,42 +581,42 @@ BEGIN
IF LEFT(ident,1) = '`' AND RIGHT(ident,1) = '`' THEN
RETURN TRIM(BOTH '`' FROM REPLACE(ident,'``','`'));
END IF;

IF LEFT(ident,1) = '"' AND RIGHT(ident,1) = '"' THEN
RETURN TRIM(BOTH '"' FROM REPLACE(ident,'""','"'));
END IF;

RETURN ident;
END //

DROP FUNCTION IF EXISTS qv //
CREATE FUNCTION qv(val TEXT) RETURNS TEXT
BEGIN
IF ISNULL(val) THEN
IF ISNULL(val) THEN
RETURN 'NULL';
END IF;

-- NB this will catch number only hex eg 000000 or 009600
IF val REGEXP '^[[:digit:]]+$' THEN
IF val REGEXP '^[[:digit:]]+$' THEN
RETURN val;
END IF;

RETURN CONCAT('\'', REPLACE(val, '''', '\\\''), '\'');
END //


DROP FUNCTION IF EXISTS dqv //
CREATE FUNCTION dqv(val TEXT) RETURNS TEXT
BEGIN
IF ISNULL(val) THEN
IF ISNULL(val) THEN
RETURN 'NULL';
END IF;

-- NB this will catch number only hex eg 000000 or 009600
IF val REGEXP '^[[:digit:]]+$' THEN
IF val REGEXP '^[[:digit:]]+$' THEN
RETURN val;
END IF;

RETURN CONCAT('"', REPLACE(val, '''', '\\\''), '"');
END //

Expand Down Expand Up @@ -759,16 +759,16 @@ BEGIN
RETURN tap;
END //

-- fix up a comma separated list of values to compare
-- fix up a comma separated list of values to compare
-- against a list of db objects
DROP FUNCTION IF EXISTS _fixCSL //
CREATE FUNCTION _fixCSL (want TEXT)
CREATE FUNCTION _fixCSL (want TEXT)
RETURNS TEXT
BEGIN

SET want = REPLACE(want, '''','');
SET want = REPLACE(want, '"','');
SET want = REPLACE(want, '\n','');
SET want = REPLACE(want, '\n','');

-- invalid characters eg NUL byte and characters > U+10000
-- IF want REGEXP '[[.NUL.]\\u10000-\\u10FFFD]' = 1 THEN
Expand All @@ -792,7 +792,7 @@ DECLARE res BOOLEAN DEFAULT TRUE;
SET msg = CONCAT('\n', CONCAT('\n'
' Extra ', what, ':\n ' , REPLACE( extras, ',', '\n ')));
END IF;

IF missing <> '' THEN
SET res = FALSE;
SET msg = CONCAT(msg, CONCAT('\n'
Expand All @@ -812,10 +812,10 @@ CREATE FUNCTION _datatype(word TEXT) RETURNS TEXT
BEGIN

SET word =
CASE
WHEN word IN ('BOOL', 'BOOLEAN') THEN 'TINYINT'
WHEN word = 'INTEGER' THEN 'INT'
WHEN word IN ('DEC', 'NUMERIC', 'FIXED') THEN 'DECIMAL'
CASE
WHEN word IN ('BOOL', 'BOOLEAN') THEN 'TINYINT'
WHEN word = 'INTEGER' THEN 'INT'
WHEN word IN ('DEC', 'NUMERIC', 'FIXED') THEN 'DECIMAL'
WHEN word IN ('DOUBLE_PRECISION') THEN 'DOUBLE'
WHEN word = 'REAL' THEN IF (INSTR(@@GLOBAL.sql_mode, 'REAL_AS_FLOAT') > 0 , 'FLOAT' , 'DOUBLE')
WHEN word IN ('NCHAR', 'CHARACTER', 'NATIONAL_CHARACTER') THEN 'CHAR'
Expand Down

0 comments on commit e21844d

Please sign in to comment.