@@ -70,144 +70,3 @@ |
||
70 | 70 | // for some reason default splitter mangles spaces on subsequent lines |
71 | 71 | $expected = [ |
72 | 72 | <<<'SQL' |
73 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
74 | - SQL, |
|
75 | - <<<'SQL' |
|
76 | - delete |
|
77 | - from |
|
78 | - foo where bar = 'some value' |
|
79 | - SQL, |
|
80 | - <<<'SQL' |
|
81 | - update dump -- I should not be ignored |
|
82 | - set message = 'I am a string with \\ backslash \' escapes and semicolons;' |
|
83 | - SQL, |
|
84 | - <<<'SQL' |
|
85 | - create procedure setfoo(newfoo int) |
|
86 | - begin |
|
87 | - set @foo = newfoo; |
|
88 | - end |
|
89 | - SQL, |
|
90 | - <<<'SQL' |
|
91 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
92 | - SQL, |
|
93 | - ]; |
|
94 | - // and insists on "\n" linebreaks |
|
95 | - foreach ($expected as &$query) { |
|
96 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
97 | - } |
|
98 | - |
|
99 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-normal.sql')); |
|
100 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
101 | - $this->project->setProperty('bar.value', 'some value'); |
|
102 | - $this->project->executeTarget('test'); |
|
103 | - |
|
104 | - $this->assertEquals($expected, $this->queries); |
|
105 | - } |
|
106 | - |
|
107 | - public function testDelimiterTypeRow(): void |
|
108 | - { |
|
109 | - // for some reason default splitter mangles spaces on subsequent lines |
|
110 | - $expected = [ |
|
111 | - <<<'SQL' |
|
112 | - insert into "duh" (foo) values ('duh') |
|
113 | - SQL, |
|
114 | - <<<'SQL' |
|
115 | - update "duh?" -- I should not be ignored |
|
116 | - set foo = 'some value' |
|
117 | - SQL, |
|
118 | - <<<'SQL' |
|
119 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
120 | - SQL, |
|
121 | - ]; |
|
122 | - // and insists on "\n" linebreaks |
|
123 | - foreach ($expected as &$query) { |
|
124 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
125 | - } |
|
126 | - |
|
127 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-row.sql')); |
|
128 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_ROW); |
|
129 | - $this->mockTask->setDelimiter('duh'); |
|
130 | - $this->project->setProperty('foo.value', 'some value'); |
|
131 | - $this->project->executeTarget('test'); |
|
132 | - |
|
133 | - $this->assertEquals($expected, $this->queries); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Checks that PDOSQLExecTask properly understands PostgreSQL dialect |
|
138 | - * (especially "dollar quoting") when working with 'pgsql:' URLs. |
|
139 | - * |
|
140 | - * @see http://www.phing.info/trac/ticket/499 |
|
141 | - * @see http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING |
|
142 | - */ |
|
143 | - public function testRequest499(): void |
|
144 | - { |
|
145 | - $expected = [ |
|
146 | - <<<'SQL' |
|
147 | - select 1 |
|
148 | - # 2 |
|
149 | - SQL, |
|
150 | - <<<'SQL' |
|
151 | - select 'foo' |
|
152 | - // 'bar' |
|
153 | - SQL, |
|
154 | - <<<'SQL' |
|
155 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
156 | - SQL, |
|
157 | - <<<'SQL' |
|
158 | - create function foo(text) |
|
159 | - returns boolean as |
|
160 | - $function$ |
|
161 | - BEGIN |
|
162 | - RETURN ($1 ~ $q$[\t\r\n\v\\]$q$); |
|
163 | - END; |
|
164 | - $function$ |
|
165 | - language plpgsql |
|
166 | - SQL, |
|
167 | - <<<'SQL' |
|
168 | - CREATE FUNCTION phingPDOtest() RETURNS "trigger" |
|
169 | - AS $_X$ |
|
170 | - if (1) |
|
171 | - { |
|
172 | - # All is well - just continue |
|
173 | - |
|
174 | - return; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - # Not good - this is probably a fatal error! |
|
179 | - elog(ERROR,"True is not true"); |
|
180 | - |
|
181 | - return "SKIP"; |
|
182 | - } |
|
183 | - $_X$ |
|
184 | - LANGUAGE plperl |
|
185 | - SQL, |
|
186 | - "insert into foo (bar) \nvalues ('some value')", |
|
187 | - <<<'SQL' |
|
188 | - insert into foo (bar) values ($$ a dollar-quoted string containing a few quotes ' ", a $placeholder$ and a semicolon;$$) |
|
189 | - SQL, |
|
190 | - <<<'SQL' |
|
191 | - create rule blah_insert |
|
192 | - as on insert to blah do instead ( |
|
193 | - insert into foo values (new.id, 'blah'); |
|
194 | - insert into bar values (new.id, 'blah-blah'); |
|
195 | - ) |
|
196 | - SQL, |
|
197 | - <<<'SQL' |
|
198 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
199 | - SQL, |
|
200 | - ]; |
|
201 | - foreach ($expected as &$query) { |
|
202 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
203 | - } |
|
204 | - |
|
205 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-pgsql.sql')); |
|
206 | - $this->mockTask->setUrl('pgsql:host=localhost;dbname=phing'); |
|
207 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
208 | - $this->project->setProperty('bar.value', 'some value'); |
|
209 | - $this->project->executeTarget('test'); |
|
210 | - |
|
211 | - $this->assertEquals($expected, $this->queries); |
|
212 | - } |
|
213 | -} |
@@ -70,144 +70,3 @@ |
||
70 | 70 | // for some reason default splitter mangles spaces on subsequent lines |
71 | 71 | $expected = [ |
72 | 72 | <<<'SQL' |
73 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
74 | - SQL, |
|
75 | - <<<'SQL' |
|
76 | - delete |
|
77 | - from |
|
78 | - foo where bar = 'some value' |
|
79 | - SQL, |
|
80 | - <<<'SQL' |
|
81 | - update dump -- I should not be ignored |
|
82 | - set message = 'I am a string with \\ backslash \' escapes and semicolons;' |
|
83 | - SQL, |
|
84 | - <<<'SQL' |
|
85 | - create procedure setfoo(newfoo int) |
|
86 | - begin |
|
87 | - set @foo = newfoo; |
|
88 | - end |
|
89 | - SQL, |
|
90 | - <<<'SQL' |
|
91 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
92 | - SQL, |
|
93 | - ]; |
|
94 | - // and insists on "\n" linebreaks |
|
95 | - foreach ($expected as &$query) { |
|
96 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
97 | - } |
|
98 | - |
|
99 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-normal.sql')); |
|
100 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
101 | - $this->project->setProperty('bar.value', 'some value'); |
|
102 | - $this->project->executeTarget('test'); |
|
103 | - |
|
104 | - $this->assertEquals($expected, $this->queries); |
|
105 | - } |
|
106 | - |
|
107 | - public function testDelimiterTypeRow(): void |
|
108 | - { |
|
109 | - // for some reason default splitter mangles spaces on subsequent lines |
|
110 | - $expected = [ |
|
111 | - <<<'SQL' |
|
112 | - insert into "duh" (foo) values ('duh') |
|
113 | - SQL, |
|
114 | - <<<'SQL' |
|
115 | - update "duh?" -- I should not be ignored |
|
116 | - set foo = 'some value' |
|
117 | - SQL, |
|
118 | - <<<'SQL' |
|
119 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
120 | - SQL, |
|
121 | - ]; |
|
122 | - // and insists on "\n" linebreaks |
|
123 | - foreach ($expected as &$query) { |
|
124 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
125 | - } |
|
126 | - |
|
127 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-row.sql')); |
|
128 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_ROW); |
|
129 | - $this->mockTask->setDelimiter('duh'); |
|
130 | - $this->project->setProperty('foo.value', 'some value'); |
|
131 | - $this->project->executeTarget('test'); |
|
132 | - |
|
133 | - $this->assertEquals($expected, $this->queries); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Checks that PDOSQLExecTask properly understands PostgreSQL dialect |
|
138 | - * (especially "dollar quoting") when working with 'pgsql:' URLs. |
|
139 | - * |
|
140 | - * @see http://www.phing.info/trac/ticket/499 |
|
141 | - * @see http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING |
|
142 | - */ |
|
143 | - public function testRequest499(): void |
|
144 | - { |
|
145 | - $expected = [ |
|
146 | - <<<'SQL' |
|
147 | - select 1 |
|
148 | - # 2 |
|
149 | - SQL, |
|
150 | - <<<'SQL' |
|
151 | - select 'foo' |
|
152 | - // 'bar' |
|
153 | - SQL, |
|
154 | - <<<'SQL' |
|
155 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
156 | - SQL, |
|
157 | - <<<'SQL' |
|
158 | - create function foo(text) |
|
159 | - returns boolean as |
|
160 | - $function$ |
|
161 | - BEGIN |
|
162 | - RETURN ($1 ~ $q$[\t\r\n\v\\]$q$); |
|
163 | - END; |
|
164 | - $function$ |
|
165 | - language plpgsql |
|
166 | - SQL, |
|
167 | - <<<'SQL' |
|
168 | - CREATE FUNCTION phingPDOtest() RETURNS "trigger" |
|
169 | - AS $_X$ |
|
170 | - if (1) |
|
171 | - { |
|
172 | - # All is well - just continue |
|
173 | - |
|
174 | - return; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - # Not good - this is probably a fatal error! |
|
179 | - elog(ERROR,"True is not true"); |
|
180 | - |
|
181 | - return "SKIP"; |
|
182 | - } |
|
183 | - $_X$ |
|
184 | - LANGUAGE plperl |
|
185 | - SQL, |
|
186 | - "insert into foo (bar) \nvalues ('some value')", |
|
187 | - <<<'SQL' |
|
188 | - insert into foo (bar) values ($$ a dollar-quoted string containing a few quotes ' ", a $placeholder$ and a semicolon;$$) |
|
189 | - SQL, |
|
190 | - <<<'SQL' |
|
191 | - create rule blah_insert |
|
192 | - as on insert to blah do instead ( |
|
193 | - insert into foo values (new.id, 'blah'); |
|
194 | - insert into bar values (new.id, 'blah-blah'); |
|
195 | - ) |
|
196 | - SQL, |
|
197 | - <<<'SQL' |
|
198 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
199 | - SQL, |
|
200 | - ]; |
|
201 | - foreach ($expected as &$query) { |
|
202 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
203 | - } |
|
204 | - |
|
205 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-pgsql.sql')); |
|
206 | - $this->mockTask->setUrl('pgsql:host=localhost;dbname=phing'); |
|
207 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
208 | - $this->project->setProperty('bar.value', 'some value'); |
|
209 | - $this->project->executeTarget('test'); |
|
210 | - |
|
211 | - $this->assertEquals($expected, $this->queries); |
|
212 | - } |
|
213 | -} |
@@ -70,144 +70,3 @@ |
||
70 | 70 | // for some reason default splitter mangles spaces on subsequent lines |
71 | 71 | $expected = [ |
72 | 72 | <<<'SQL' |
73 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
74 | - SQL, |
|
75 | - <<<'SQL' |
|
76 | - delete |
|
77 | - from |
|
78 | - foo where bar = 'some value' |
|
79 | - SQL, |
|
80 | - <<<'SQL' |
|
81 | - update dump -- I should not be ignored |
|
82 | - set message = 'I am a string with \\ backslash \' escapes and semicolons;' |
|
83 | - SQL, |
|
84 | - <<<'SQL' |
|
85 | - create procedure setfoo(newfoo int) |
|
86 | - begin |
|
87 | - set @foo = newfoo; |
|
88 | - end |
|
89 | - SQL, |
|
90 | - <<<'SQL' |
|
91 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
92 | - SQL, |
|
93 | - ]; |
|
94 | - // and insists on "\n" linebreaks |
|
95 | - foreach ($expected as &$query) { |
|
96 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
97 | - } |
|
98 | - |
|
99 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-normal.sql')); |
|
100 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
101 | - $this->project->setProperty('bar.value', 'some value'); |
|
102 | - $this->project->executeTarget('test'); |
|
103 | - |
|
104 | - $this->assertEquals($expected, $this->queries); |
|
105 | - } |
|
106 | - |
|
107 | - public function testDelimiterTypeRow(): void |
|
108 | - { |
|
109 | - // for some reason default splitter mangles spaces on subsequent lines |
|
110 | - $expected = [ |
|
111 | - <<<'SQL' |
|
112 | - insert into "duh" (foo) values ('duh') |
|
113 | - SQL, |
|
114 | - <<<'SQL' |
|
115 | - update "duh?" -- I should not be ignored |
|
116 | - set foo = 'some value' |
|
117 | - SQL, |
|
118 | - <<<'SQL' |
|
119 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
120 | - SQL, |
|
121 | - ]; |
|
122 | - // and insists on "\n" linebreaks |
|
123 | - foreach ($expected as &$query) { |
|
124 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
125 | - } |
|
126 | - |
|
127 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-row.sql')); |
|
128 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_ROW); |
|
129 | - $this->mockTask->setDelimiter('duh'); |
|
130 | - $this->project->setProperty('foo.value', 'some value'); |
|
131 | - $this->project->executeTarget('test'); |
|
132 | - |
|
133 | - $this->assertEquals($expected, $this->queries); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Checks that PDOSQLExecTask properly understands PostgreSQL dialect |
|
138 | - * (especially "dollar quoting") when working with 'pgsql:' URLs. |
|
139 | - * |
|
140 | - * @see http://www.phing.info/trac/ticket/499 |
|
141 | - * @see http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING |
|
142 | - */ |
|
143 | - public function testRequest499(): void |
|
144 | - { |
|
145 | - $expected = [ |
|
146 | - <<<'SQL' |
|
147 | - select 1 |
|
148 | - # 2 |
|
149 | - SQL, |
|
150 | - <<<'SQL' |
|
151 | - select 'foo' |
|
152 | - // 'bar' |
|
153 | - SQL, |
|
154 | - <<<'SQL' |
|
155 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
156 | - SQL, |
|
157 | - <<<'SQL' |
|
158 | - create function foo(text) |
|
159 | - returns boolean as |
|
160 | - $function$ |
|
161 | - BEGIN |
|
162 | - RETURN ($1 ~ $q$[\t\r\n\v\\]$q$); |
|
163 | - END; |
|
164 | - $function$ |
|
165 | - language plpgsql |
|
166 | - SQL, |
|
167 | - <<<'SQL' |
|
168 | - CREATE FUNCTION phingPDOtest() RETURNS "trigger" |
|
169 | - AS $_X$ |
|
170 | - if (1) |
|
171 | - { |
|
172 | - # All is well - just continue |
|
173 | - |
|
174 | - return; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - # Not good - this is probably a fatal error! |
|
179 | - elog(ERROR,"True is not true"); |
|
180 | - |
|
181 | - return "SKIP"; |
|
182 | - } |
|
183 | - $_X$ |
|
184 | - LANGUAGE plperl |
|
185 | - SQL, |
|
186 | - "insert into foo (bar) \nvalues ('some value')", |
|
187 | - <<<'SQL' |
|
188 | - insert into foo (bar) values ($$ a dollar-quoted string containing a few quotes ' ", a $placeholder$ and a semicolon;$$) |
|
189 | - SQL, |
|
190 | - <<<'SQL' |
|
191 | - create rule blah_insert |
|
192 | - as on insert to blah do instead ( |
|
193 | - insert into foo values (new.id, 'blah'); |
|
194 | - insert into bar values (new.id, 'blah-blah'); |
|
195 | - ) |
|
196 | - SQL, |
|
197 | - <<<'SQL' |
|
198 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
199 | - SQL, |
|
200 | - ]; |
|
201 | - foreach ($expected as &$query) { |
|
202 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
203 | - } |
|
204 | - |
|
205 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-pgsql.sql')); |
|
206 | - $this->mockTask->setUrl('pgsql:host=localhost;dbname=phing'); |
|
207 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
208 | - $this->project->setProperty('bar.value', 'some value'); |
|
209 | - $this->project->executeTarget('test'); |
|
210 | - |
|
211 | - $this->assertEquals($expected, $this->queries); |
|
212 | - } |
|
213 | -} |
@@ -70,144 +70,3 @@ |
||
70 | 70 | // for some reason default splitter mangles spaces on subsequent lines |
71 | 71 | $expected = [ |
72 | 72 | <<<'SQL' |
73 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
74 | - SQL, |
|
75 | - <<<'SQL' |
|
76 | - delete |
|
77 | - from |
|
78 | - foo where bar = 'some value' |
|
79 | - SQL, |
|
80 | - <<<'SQL' |
|
81 | - update dump -- I should not be ignored |
|
82 | - set message = 'I am a string with \\ backslash \' escapes and semicolons;' |
|
83 | - SQL, |
|
84 | - <<<'SQL' |
|
85 | - create procedure setfoo(newfoo int) |
|
86 | - begin |
|
87 | - set @foo = newfoo; |
|
88 | - end |
|
89 | - SQL, |
|
90 | - <<<'SQL' |
|
91 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
92 | - SQL, |
|
93 | - ]; |
|
94 | - // and insists on "\n" linebreaks |
|
95 | - foreach ($expected as &$query) { |
|
96 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
97 | - } |
|
98 | - |
|
99 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-normal.sql')); |
|
100 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
101 | - $this->project->setProperty('bar.value', 'some value'); |
|
102 | - $this->project->executeTarget('test'); |
|
103 | - |
|
104 | - $this->assertEquals($expected, $this->queries); |
|
105 | - } |
|
106 | - |
|
107 | - public function testDelimiterTypeRow(): void |
|
108 | - { |
|
109 | - // for some reason default splitter mangles spaces on subsequent lines |
|
110 | - $expected = [ |
|
111 | - <<<'SQL' |
|
112 | - insert into "duh" (foo) values ('duh') |
|
113 | - SQL, |
|
114 | - <<<'SQL' |
|
115 | - update "duh?" -- I should not be ignored |
|
116 | - set foo = 'some value' |
|
117 | - SQL, |
|
118 | - <<<'SQL' |
|
119 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
120 | - SQL, |
|
121 | - ]; |
|
122 | - // and insists on "\n" linebreaks |
|
123 | - foreach ($expected as &$query) { |
|
124 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
125 | - } |
|
126 | - |
|
127 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-row.sql')); |
|
128 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_ROW); |
|
129 | - $this->mockTask->setDelimiter('duh'); |
|
130 | - $this->project->setProperty('foo.value', 'some value'); |
|
131 | - $this->project->executeTarget('test'); |
|
132 | - |
|
133 | - $this->assertEquals($expected, $this->queries); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Checks that PDOSQLExecTask properly understands PostgreSQL dialect |
|
138 | - * (especially "dollar quoting") when working with 'pgsql:' URLs. |
|
139 | - * |
|
140 | - * @see http://www.phing.info/trac/ticket/499 |
|
141 | - * @see http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING |
|
142 | - */ |
|
143 | - public function testRequest499(): void |
|
144 | - { |
|
145 | - $expected = [ |
|
146 | - <<<'SQL' |
|
147 | - select 1 |
|
148 | - # 2 |
|
149 | - SQL, |
|
150 | - <<<'SQL' |
|
151 | - select 'foo' |
|
152 | - // 'bar' |
|
153 | - SQL, |
|
154 | - <<<'SQL' |
|
155 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
156 | - SQL, |
|
157 | - <<<'SQL' |
|
158 | - create function foo(text) |
|
159 | - returns boolean as |
|
160 | - $function$ |
|
161 | - BEGIN |
|
162 | - RETURN ($1 ~ $q$[\t\r\n\v\\]$q$); |
|
163 | - END; |
|
164 | - $function$ |
|
165 | - language plpgsql |
|
166 | - SQL, |
|
167 | - <<<'SQL' |
|
168 | - CREATE FUNCTION phingPDOtest() RETURNS "trigger" |
|
169 | - AS $_X$ |
|
170 | - if (1) |
|
171 | - { |
|
172 | - # All is well - just continue |
|
173 | - |
|
174 | - return; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - # Not good - this is probably a fatal error! |
|
179 | - elog(ERROR,"True is not true"); |
|
180 | - |
|
181 | - return "SKIP"; |
|
182 | - } |
|
183 | - $_X$ |
|
184 | - LANGUAGE plperl |
|
185 | - SQL, |
|
186 | - "insert into foo (bar) \nvalues ('some value')", |
|
187 | - <<<'SQL' |
|
188 | - insert into foo (bar) values ($$ a dollar-quoted string containing a few quotes ' ", a $placeholder$ and a semicolon;$$) |
|
189 | - SQL, |
|
190 | - <<<'SQL' |
|
191 | - create rule blah_insert |
|
192 | - as on insert to blah do instead ( |
|
193 | - insert into foo values (new.id, 'blah'); |
|
194 | - insert into bar values (new.id, 'blah-blah'); |
|
195 | - ) |
|
196 | - SQL, |
|
197 | - <<<'SQL' |
|
198 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
199 | - SQL, |
|
200 | - ]; |
|
201 | - foreach ($expected as &$query) { |
|
202 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
203 | - } |
|
204 | - |
|
205 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-pgsql.sql')); |
|
206 | - $this->mockTask->setUrl('pgsql:host=localhost;dbname=phing'); |
|
207 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
208 | - $this->project->setProperty('bar.value', 'some value'); |
|
209 | - $this->project->executeTarget('test'); |
|
210 | - |
|
211 | - $this->assertEquals($expected, $this->queries); |
|
212 | - } |
|
213 | -} |
@@ -70,144 +70,3 @@ |
||
70 | 70 | // for some reason default splitter mangles spaces on subsequent lines |
71 | 71 | $expected = [ |
72 | 72 | <<<'SQL' |
73 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
74 | - SQL, |
|
75 | - <<<'SQL' |
|
76 | - delete |
|
77 | - from |
|
78 | - foo where bar = 'some value' |
|
79 | - SQL, |
|
80 | - <<<'SQL' |
|
81 | - update dump -- I should not be ignored |
|
82 | - set message = 'I am a string with \\ backslash \' escapes and semicolons;' |
|
83 | - SQL, |
|
84 | - <<<'SQL' |
|
85 | - create procedure setfoo(newfoo int) |
|
86 | - begin |
|
87 | - set @foo = newfoo; |
|
88 | - end |
|
89 | - SQL, |
|
90 | - <<<'SQL' |
|
91 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
92 | - SQL, |
|
93 | - ]; |
|
94 | - // and insists on "\n" linebreaks |
|
95 | - foreach ($expected as &$query) { |
|
96 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
97 | - } |
|
98 | - |
|
99 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-normal.sql')); |
|
100 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
101 | - $this->project->setProperty('bar.value', 'some value'); |
|
102 | - $this->project->executeTarget('test'); |
|
103 | - |
|
104 | - $this->assertEquals($expected, $this->queries); |
|
105 | - } |
|
106 | - |
|
107 | - public function testDelimiterTypeRow(): void |
|
108 | - { |
|
109 | - // for some reason default splitter mangles spaces on subsequent lines |
|
110 | - $expected = [ |
|
111 | - <<<'SQL' |
|
112 | - insert into "duh" (foo) values ('duh') |
|
113 | - SQL, |
|
114 | - <<<'SQL' |
|
115 | - update "duh?" -- I should not be ignored |
|
116 | - set foo = 'some value' |
|
117 | - SQL, |
|
118 | - <<<'SQL' |
|
119 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
120 | - SQL, |
|
121 | - ]; |
|
122 | - // and insists on "\n" linebreaks |
|
123 | - foreach ($expected as &$query) { |
|
124 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
125 | - } |
|
126 | - |
|
127 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-row.sql')); |
|
128 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_ROW); |
|
129 | - $this->mockTask->setDelimiter('duh'); |
|
130 | - $this->project->setProperty('foo.value', 'some value'); |
|
131 | - $this->project->executeTarget('test'); |
|
132 | - |
|
133 | - $this->assertEquals($expected, $this->queries); |
|
134 | - } |
|
135 | - |
|
136 | - /** |
|
137 | - * Checks that PDOSQLExecTask properly understands PostgreSQL dialect |
|
138 | - * (especially "dollar quoting") when working with 'pgsql:' URLs. |
|
139 | - * |
|
140 | - * @see http://www.phing.info/trac/ticket/499 |
|
141 | - * @see http://www.postgresql.org/docs/9.0/interactive/sql-syntax-lexical.html#SQL-SYNTAX-DOLLAR-QUOTING |
|
142 | - */ |
|
143 | - public function testRequest499(): void |
|
144 | - { |
|
145 | - $expected = [ |
|
146 | - <<<'SQL' |
|
147 | - select 1 |
|
148 | - # 2 |
|
149 | - SQL, |
|
150 | - <<<'SQL' |
|
151 | - select 'foo' |
|
152 | - // 'bar' |
|
153 | - SQL, |
|
154 | - <<<'SQL' |
|
155 | - insert into foo (bar, "strange;name""indeed") values ('bar''s value containing ;', 'a value for strange named column') |
|
156 | - SQL, |
|
157 | - <<<'SQL' |
|
158 | - create function foo(text) |
|
159 | - returns boolean as |
|
160 | - $function$ |
|
161 | - BEGIN |
|
162 | - RETURN ($1 ~ $q$[\t\r\n\v\\]$q$); |
|
163 | - END; |
|
164 | - $function$ |
|
165 | - language plpgsql |
|
166 | - SQL, |
|
167 | - <<<'SQL' |
|
168 | - CREATE FUNCTION phingPDOtest() RETURNS "trigger" |
|
169 | - AS $_X$ |
|
170 | - if (1) |
|
171 | - { |
|
172 | - # All is well - just continue |
|
173 | - |
|
174 | - return; |
|
175 | - } |
|
176 | - else |
|
177 | - { |
|
178 | - # Not good - this is probably a fatal error! |
|
179 | - elog(ERROR,"True is not true"); |
|
180 | - |
|
181 | - return "SKIP"; |
|
182 | - } |
|
183 | - $_X$ |
|
184 | - LANGUAGE plperl |
|
185 | - SQL, |
|
186 | - "insert into foo (bar) \nvalues ('some value')", |
|
187 | - <<<'SQL' |
|
188 | - insert into foo (bar) values ($$ a dollar-quoted string containing a few quotes ' ", a $placeholder$ and a semicolon;$$) |
|
189 | - SQL, |
|
190 | - <<<'SQL' |
|
191 | - create rule blah_insert |
|
192 | - as on insert to blah do instead ( |
|
193 | - insert into foo values (new.id, 'blah'); |
|
194 | - insert into bar values (new.id, 'blah-blah'); |
|
195 | - ) |
|
196 | - SQL, |
|
197 | - <<<'SQL' |
|
198 | - insert into dump (message) values ('I am a statement not ending with a delimiter') |
|
199 | - SQL, |
|
200 | - ]; |
|
201 | - foreach ($expected as &$query) { |
|
202 | - $query = str_replace(["\n\n", "\r"], ["\n", ''], $query); |
|
203 | - } |
|
204 | - |
|
205 | - $this->mockTask->setSrc(new File(PHING_TEST_BASE . '/etc/tasks/ext/pdo/delimiters-pgsql.sql')); |
|
206 | - $this->mockTask->setUrl('pgsql:host=localhost;dbname=phing'); |
|
207 | - $this->mockTask->setDelimiterType(PDOSQLExecTask::DELIM_NORMAL); |
|
208 | - $this->project->setProperty('bar.value', 'some value'); |
|
209 | - $this->project->executeTarget('test'); |
|
210 | - |
|
211 | - $this->assertEquals($expected, $this->queries); |
|
212 | - } |
|
213 | -} |