Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make the postgresql loader load $$ syntax correctly #1450

Merged

Conversation

rtuin
Copy link
Contributor

@rtuin rtuin commented Oct 8, 2014

I found it to be impossible to import postgresql triggers made with the $$ syntax, so I fixed it.
To fix it I had to copy paste the entire loader code from the abstract Db driver and added some extra parsing logic. Perhaps there is a better way to fix it, and I'm open for input on that.

This is the SQL code that didn't work:

-- test for triggers with $$ syntax
CREATE OR REPLACE FUNCTION upd_timestamp() RETURNS TRIGGER
LANGUAGE plpgsql
AS
$$
BEGIN
    NEW.created_at = CURRENT_TIMESTAMP;
    RETURN NEW;
END;
$$;

Without the fix I got this error in the testsuite

There was 1 error:

---------
1) postgresTest::testLoadDump
PDOException: SQLSTATE[42601]: Syntax error: 7 ERROR:  unterminated dollar-quoted string at or near "$$
BEGIN
    NEW.created_at = CURRENT_TIMESTAMP"
LINE 5: $$
        ^

With the fix the SQL code gets imported without any problems.

Please let me know what you think!

@rtuin
Copy link
Contributor Author

rtuin commented Oct 8, 2014

This should also solve the problem reported in this issue: #1128

@rtuin
Copy link
Contributor Author

rtuin commented Oct 8, 2014

The CI build seems to be failing because of an error unrelated to this change. Is this a known issue?

@rtuin rtuin force-pushed the feature/2.0-fix-dollar-dollar-trigger-notation branch from 8bdc063 to 34f9687 Compare October 9, 2014 06:53
@DavertMik
Copy link
Member

Looks nice. Thank you!

DavertMik added a commit that referenced this pull request Oct 11, 2014
…gger-notation

Make the postgresql loader load $$ syntax correctly
@DavertMik DavertMik merged commit c945484 into Codeception:2.0 Oct 11, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants