-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Proper support for upper case table names
Merge pull request #21 from nearform/yktv4-camel-case-support
- Loading branch information
Showing
8 changed files
with
260 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,153 @@ | ||
CREATE TABLE "Versioning" (a bigint, "b b" date, sys_period tstzrange); | ||
-- Insert some data before versioning is enabled. | ||
INSERT INTO "Versioning" (a, sys_period) VALUES (1, tstzrange('-infinity', NULL)); | ||
INSERT INTO "Versioning" (a, sys_period) VALUES (2, tstzrange('2000-01-01', NULL)); | ||
CREATE TABLE "VersioningHistory" (a bigint, c date, sys_period tstzrange); | ||
CREATE TRIGGER "VersioningTrigger" | ||
BEFORE INSERT OR UPDATE OR DELETE ON "Versioning" | ||
FOR EACH ROW EXECUTE PROCEDURE versioning('sys_period', '"VersioningHistory"', false); | ||
-- Insert. | ||
BEGIN; | ||
INSERT INTO "Versioning" (a) VALUES (3); | ||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
a | b b | ?column? | ||
---+-----+---------- | ||
1 | | f | ||
2 | | f | ||
3 | | t | ||
(3 rows) | ||
|
||
SELECT * FROM "VersioningHistory" ORDER BY a, sys_period; | ||
a | c | sys_period | ||
---+---+------------ | ||
(0 rows) | ||
|
||
COMMIT; | ||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
-- Update. | ||
BEGIN; | ||
UPDATE "Versioning" SET a = 4 WHERE a = 3; | ||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
a | b b | ?column? | ||
---+-----+---------- | ||
1 | | f | ||
2 | | f | ||
4 | | t | ||
(3 rows) | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
a | c | ?column? | ||
---+---+---------- | ||
3 | | t | ||
(1 row) | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
a | b b | ||
---+----- | ||
4 | | ||
(1 row) | ||
|
||
COMMIT; | ||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
-- Multiple updates. | ||
BEGIN; | ||
UPDATE "Versioning" SET a = 5 WHERE a = 4; | ||
UPDATE "Versioning" SET "b b" = '2012-01-01' WHERE a = 5; | ||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
a | b b | ?column? | ||
---+------------+---------- | ||
1 | | f | ||
2 | | f | ||
5 | 2012-01-01 | t | ||
(3 rows) | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
a | c | ?column? | ||
---+---+---------- | ||
3 | | f | ||
4 | | t | ||
(2 rows) | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
a | b b | ||
---+------------ | ||
5 | 2012-01-01 | ||
(1 row) | ||
|
||
COMMIT; | ||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
-- Delete. | ||
BEGIN; | ||
DELETE FROM "Versioning" WHERE a = 4; | ||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
a | b b | ?column? | ||
---+------------+---------- | ||
1 | | f | ||
2 | | f | ||
5 | 2012-01-01 | f | ||
(3 rows) | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
a | c | ?column? | ||
---+---+---------- | ||
3 | | f | ||
4 | | f | ||
(2 rows) | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
a | b b | ||
---+----- | ||
(0 rows) | ||
|
||
END; | ||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
pg_sleep | ||
---------- | ||
|
||
(1 row) | ||
|
||
-- Delete. | ||
BEGIN; | ||
DELETE FROM "Versioning"; | ||
SELECT * FROM "Versioning"; | ||
a | b b | sys_period | ||
---+-----+------------ | ||
(0 rows) | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
a | c | ?column? | ||
---+---+---------- | ||
1 | | t | ||
2 | | t | ||
3 | | f | ||
4 | | f | ||
5 | | t | ||
(5 rows) | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
a | b b | ||
---+----- | ||
(0 rows) | ||
|
||
END; | ||
DROP TABLE "Versioning"; | ||
DROP TABLE "VersioningHistory"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
CREATE TABLE "Versioning" (a bigint, "b b" date, sys_period tstzrange); | ||
|
||
-- Insert some data before versioning is enabled. | ||
INSERT INTO "Versioning" (a, sys_period) VALUES (1, tstzrange('-infinity', NULL)); | ||
INSERT INTO "Versioning" (a, sys_period) VALUES (2, tstzrange('2000-01-01', NULL)); | ||
|
||
CREATE TABLE "VersioningHistory" (a bigint, c date, sys_period tstzrange); | ||
|
||
CREATE TRIGGER "VersioningTrigger" | ||
BEFORE INSERT OR UPDATE OR DELETE ON "Versioning" | ||
FOR EACH ROW EXECUTE PROCEDURE versioning('sys_period', '"VersioningHistory"', false); | ||
|
||
-- Insert. | ||
BEGIN; | ||
|
||
INSERT INTO "Versioning" (a) VALUES (3); | ||
|
||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
|
||
SELECT * FROM "VersioningHistory" ORDER BY a, sys_period; | ||
|
||
COMMIT; | ||
|
||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
|
||
-- Update. | ||
BEGIN; | ||
|
||
UPDATE "Versioning" SET a = 4 WHERE a = 3; | ||
|
||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
|
||
COMMIT; | ||
|
||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
|
||
-- Multiple updates. | ||
BEGIN; | ||
|
||
UPDATE "Versioning" SET a = 5 WHERE a = 4; | ||
UPDATE "Versioning" SET "b b" = '2012-01-01' WHERE a = 5; | ||
|
||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
|
||
COMMIT; | ||
|
||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
|
||
-- Delete. | ||
BEGIN; | ||
|
||
DELETE FROM "Versioning" WHERE a = 4; | ||
|
||
SELECT a, "b b", lower(sys_period) = CURRENT_TIMESTAMP FROM "Versioning" ORDER BY a, sys_period; | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
|
||
END; | ||
|
||
-- Make sure that the next transaction's CURRENT_TIMESTAMP is different. | ||
SELECT pg_sleep(0.1); | ||
|
||
-- Delete. | ||
BEGIN; | ||
|
||
DELETE FROM "Versioning"; | ||
|
||
SELECT * FROM "Versioning"; | ||
|
||
SELECT a, c, upper(sys_period) = CURRENT_TIMESTAMP FROM "VersioningHistory" ORDER BY a, sys_period; | ||
|
||
SELECT a, "b b" FROM "Versioning" WHERE lower(sys_period) = CURRENT_TIMESTAMP ORDER BY a, sys_period; | ||
|
||
END; | ||
|
||
DROP TABLE "Versioning"; | ||
DROP TABLE "VersioningHistory"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters