Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Convert some `generate_series()`s to `unnest()`s.

  • Loading branch information...
commit d8d517fdf9d8c1ac7f1caa49c480730631696937 1 parent 5a348e4
@theory authored
View
BIN  tddd.key
Binary file not shown
View
2  tests/027-flipfunc.pg
@@ -54,7 +54,7 @@ CREATE OR REPLACE FUNCTION add_fids(
ALTER SEQUENCE fidseq RESTART;
DELETE FROM fids;
INSERT INTO fids (fid)
- SELECT $1[i] FROM generate_series(1, array_upper($1, 1)) AS i
+ SELECT n FROM unnest($1) AS n;
$$;
CREATE OR REPLACE FUNCTION mock.clock_timestamp(
View
7 tests/028-flipfunc.pg
@@ -54,7 +54,7 @@ CREATE OR REPLACE FUNCTION add_fids(
ALTER SEQUENCE fidseq RESTART;
DELETE FROM fids;
INSERT INTO fids (fid)
- SELECT $1[i] FROM generate_series(1, array_upper($1, 1)) AS i
+ SELECT n FROM unnest($1) AS n;
$$;
CREATE OR REPLACE FUNCTION mock.clock_timestamp(
@@ -98,8 +98,9 @@ SELECT is(
'Inserted row should be correct'
) FROM flips WHERE id = 'a';
-SELECT ins_user((ARRAY['drickles', 'mali', 'gmarx'])[i], '*****')
-FROM generate_series(1,3) AS i;
+
+SELECT ins_user(nick, '*****')
+FROM unnest(ARRAY['drickles', 'mali', 'gmarx']) AS nick;
SELECT add_fids('b', 'c', 'd');
View
24 tests/029-flipfunc.pg
@@ -54,7 +54,7 @@ CREATE OR REPLACE FUNCTION add_fids(
ALTER SEQUENCE fidseq RESTART;
DELETE FROM fids;
INSERT INTO fids (fid)
- SELECT $1[i] FROM generate_series(1, array_upper($1, 1)) AS i
+ SELECT n FROM unnest($1) AS n;
$$;
CREATE OR REPLACE FUNCTION mock.clock_timestamp(
@@ -98,8 +98,8 @@ SELECT is(
'Inserted row should be correct'
) FROM flips WHERE id = 'a';
-SELECT ins_user((ARRAY['drickles', 'mali', 'gmarx'])[i], '*****')
-FROM generate_series(1,3) AS i;
+SELECT ins_user(nick, '*****')
+FROM unnest(ARRAY['drickles', 'mali', 'gmarx']) AS nick;
SELECT add_fids('b', 'c', 'd');
@@ -128,15 +128,15 @@ SELECT add_fids('e', 'f', 'g', 'h', 'i', 'j');
-- Lots of Rickles.
SELECT ok(
- ins_flip('drickles', (ARRAY[
- 'Who picks your clothes — Stevie Wonder?',
- 'Do yourself a favormake an appointment with a brain surgeon',
- 'Why are you always speeding? It’s not like you’ve got people holding their breath til you get there',
- 'Personally, I liked you better when you were on the cover of “Mad magazine”',
- 'Don’t look now, but something died on your head',
- 'Let’s face it -- you put the “suck” in “success”'
- ])[i]) <> 'a'
-) FROM generate_series(1, 6) AS i;
+ ins_flip('drickles', body) <> 'a'
+) FROM unnest(ARRAY[
+ 'Who picks your clothesStevie Wonder?',
+ 'Do yourself a favor — make an appointment with a brain surgeon',
+ 'Why are you always speeding? It’s not like you’ve got people holding their breath til you get there',
+ 'Personally, I liked you better when you were on the cover of “Mad magazine”',
+ 'Don’t look now, but something died on your head',
+ 'Let’s face it -- you put the “suck” in “success”'
+]) AS body;
SELECT * FROM finish();
ROLLBACK;
View
24 tests/030-flipfunc.pg
@@ -54,7 +54,7 @@ CREATE OR REPLACE FUNCTION add_fids(
ALTER SEQUENCE fidseq RESTART;
DELETE FROM fids;
INSERT INTO fids (fid)
- SELECT $1[i] FROM generate_series(1, array_upper($1, 1)) AS i
+ SELECT n FROM unnest($1) AS n;
$$;
CREATE OR REPLACE FUNCTION mock.clock_timestamp(
@@ -98,8 +98,8 @@ SELECT is(
'Inserted row should be correct'
) FROM flips WHERE id = 'a';
-SELECT ins_user((ARRAY['drickles', 'mali', 'gmarx'])[i], '*****')
-FROM generate_series(1,3) AS i;
+SELECT ins_user(nick, '*****')
+FROM unnest(ARRAY['drickles', 'mali', 'gmarx']) AS nick;
SELECT add_fids('b', 'c', 'd');
@@ -128,15 +128,15 @@ SELECT add_fids('e', 'f', 'g', 'h', 'i', 'j');
-- Lots of Rickles.
SELECT ok(
- ins_flip('drickles', (ARRAY[
- 'Who picks your clothes — Stevie Wonder?',
- 'Do yourself a favormake an appointment with a brain surgeon',
- 'Why are you always speeding? It’s not like you’ve got people holding their breath til you get there',
- 'Personally, I liked you better when you were on the cover of “Mad magazine”',
- 'Don’t look now, but something died on your head',
- 'Let’s face it -- you put the “suck” in “success”'
- ])[i]) <> 'a'
-) FROM generate_series(1, 6) AS i;
+ ins_flip('drickles', body) <> 'a'
+) FROM unnest(ARRAY[
+ 'Who picks your clothesStevie Wonder?',
+ 'Do yourself a favor — make an appointment with a brain surgeon',
+ 'Why are you always speeding? It’s not like you’ve got people holding their breath til you get there',
+ 'Personally, I liked you better when you were on the cover of “Mad magazine”',
+ 'Don’t look now, but something died on your head',
+ 'Let’s face it -- you put the “suck” in “success”'
+]) AS body;
-- Test del_flip().
SELECT has_function('del_flip');
View
35 tests/031-flipfunc.pg
@@ -54,7 +54,7 @@ CREATE OR REPLACE FUNCTION add_fids(
ALTER SEQUENCE fidseq RESTART;
DELETE FROM fids;
INSERT INTO fids (fid)
- SELECT $1[i] FROM generate_series(1, array_upper($1, 1)) AS i
+ SELECT n FROM unnest($1) AS n;
$$;
CREATE OR REPLACE FUNCTION mock.clock_timestamp(
@@ -98,8 +98,8 @@ SELECT is(
'Inserted row should be correct'
) FROM flips WHERE id = 'a';
-SELECT ins_user((ARRAY['drickles', 'mali', 'gmarx'])[i], '*****')
-FROM generate_series(1,3) AS i;
+SELECT ins_user(nick, '*****')
+FROM unnest(ARRAY['drickles', 'mali', 'gmarx']) AS nick;
SELECT add_fids('b', 'c', 'd');
@@ -128,21 +128,22 @@ SELECT add_fids('e', 'f', 'g', 'h', 'i', 'j');
-- Lots of Rickles.
SELECT ok(
- ins_flip('drickles', (ARRAY[
- 'Who picks your clothes — Stevie Wonder?',
- 'Do yourself a favormake an appointment with a brain surgeon',
- 'Why are you always speeding? It’s not like you’ve got people holding their breath til you get there',
- 'Personally, I liked you better when you were on the cover of “Mad magazine”',
- 'Don’t look now, but something died on your head',
- 'Let’s face it -- you put the “suck” in “success”'
- ])[i]) <> 'a'
-) FROM generate_series(1, 6) AS i;
-
--- Fixtures stuff.
+ ins_flip('drickles', body) <> 'a'
+) FROM unnest(ARRAY[
+ 'Who picks your clothesStevie Wonder?',
+ 'Do yourself a favor — make an appointment with a brain surgeon',
+ 'Why are you always speeding? It’s not like you’ve got people holding their breath til you get there',
+ 'Personally, I liked you better when you were on the cover of “Mad magazine”',
+ 'Don’t look now, but something died on your head',
+ 'Let’s face it -- you put the “suck” in “success”'
+]) AS body;
+
+-- -- Fixtures stuff.
-- SELECT add_fids('k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u');
-- -- Lots of Marx.
-- SELECT ok(
--- ins_flip('gmarx', (ARRAY[
+-- ins_flip('gmarx', body) <> 'a'
+-- ) FROM unnest(ARRAY[
-- 'You’ve got the brain of a four-year-old boy, and I bet he was glad to get rid of it.',
-- 'Why don’t you bore a hole in yourself and let the sap run out?',
-- 'Either you’re dead or my watch has stopped.',
@@ -154,9 +155,7 @@ SELECT ok(
-- 'You know I could rent you out as a decoy for duck hunters?',
-- 'Do you think I could buy back my introduction to you?',
-- 'I never forget a face, but in your case I’ll make an exception.'
--- ])[i]) <> 'a'
--- ) FROM generate_series(1, 5) AS i;
-
+-- ]) AS body;
-- COPY flips to STDOUT CSV;
-- COPY(SELECT id, nickname, body, timestamp, NULL FROM flips) TO STDOUT CSV;
View
4 tests/032-ignorfunc.sql → tests/032-ignorfunc.pg
@@ -13,8 +13,8 @@ SELECT volatility_is('ins_ignore', 'volatile');
SELECT is_definer('ins_ignore');
-- Insert some users.
-SELECT ins_user((ARRAY['jrivers', 'drickles', 'mali', 'gmarx'])[i], '*****')
-FROM generate_series(1,4) AS i;
+SELECT ins_user(nick, '*****')
+FROM unnest(ARRAY['jrivers', 'drickles', 'mali', 'gmarx']) AS nick;
SELECT is(
COUNT(*)::INT, 0,
Please sign in to comment.
Something went wrong with that request. Please try again.