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

Ensure all integration tests to pass on PostgreSQL #1140

Closed
0pdd opened this issue Oct 22, 2019 · 9 comments
Closed

Ensure all integration tests to pass on PostgreSQL #1140

0pdd opened this issue Oct 22, 2019 · 9 comments

Comments

@0pdd
Copy link

0pdd commented Oct 22, 2019

The puzzle 1054-7feb00d4 from #1054 has to be resolved:

# @todo #1054 Ensure all integration tests to pass on PostgreSQL

The puzzle was created by Slava Semushin on 19-Oct-19.

@0pdd 0pdd added the techdebt label Oct 22, 2019
0pdd referenced this issue Oct 22, 2019
The error was:
ERROR: src/main/resources/application-postgres.properties; puzzle at line #42; Space expected at
43:2; make sure all lines in the puzzle body have a single leading space.

[skip ci]
@php-coder php-coder self-assigned this Oct 22, 2019
@php-coder php-coder added this to the 0.4.2 milestone Oct 22, 2019
@php-coder
Copy link
Owner

php-coder commented Oct 23, 2019

Failure 1: when user adds a series to the collection.

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE collections c SET c.updated_at = ? , c.updated_by = ? WHERE c.user_id = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: column "c" of relation "collections" does not exist

@php-coder
Copy link
Owner

Failure 1: when user adds a series to the collection.

It worked after removing table alias (c) from query.


Failure 2: when user adds a series to the collection.

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT CASE WHEN 'ru' = ? THEN COALESCE(c.name_ru, c.name) ELSE c.name END AS name , SUM(s.quantity) AS counter FROM collections_series cs JOIN series s ON s.id = cs.series_id JOIN categories c ON c.id = s.category_id WHERE cs.collection_id = ? GROUP BY s.category_id]; nested exception is org.postgresql.util.PSQLException: ERROR: column "c.name_ru" must appear in the GROUP BY clause or be used in an aggregate function

@php-coder
Copy link
Owner

php-coder added a commit that referenced this issue Oct 23, 2019
The error was:
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE
collections c SET c.updated_at = ? , c.updated_by = ? WHERE c.user_id = ?]; nested exception is
org.postgresql.util.PSQLException: ERROR: column "c" of relation "collections" does not exist

Part of #1140
@php-coder
Copy link
Owner

Failure 3: when admin adds additional image:

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE series s SET s.updated_at = ? , s.updated_by = ? WHERE s.id = ?]; nested exception is org.postgresql.util.PSQLException: ERROR: column "s" of relation "series" does not exist

php-coder added a commit that referenced this issue Oct 24, 2019
The error was:
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [UPDATE
series s SET s.updated_at = ? , s.updated_by = ? WHERE s.id = ?]; nested exception is
org.postgresql.util.PSQLException: ERROR: column "s" of relation "series" does not exist

Part of #1140
@php-coder
Copy link
Owner

Failure 4: when user creates a series with Michel catalog numbers:

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [INSERT INTO michel_catalog(code) SELECT ? AS code FROM dual WHERE NOT EXISTS( SELECT * FROM michel_catalog WHERE code = ? )]; nested exception is org.postgresql.util.PSQLException: ERROR: relation "dual" does not exist

@php-coder
Copy link
Owner

Failure 5: when user adds a series to the collection

org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT COALESCE(CASE WHEN 'ru' = ? THEN COALESCE(c.name_ru, c.name) ELSE c.name END, 'Unknown') AS name , SUM(s.quantity) AS counter FROM collections_series cs JOIN series s ON s.id = cs.series_id LEFT JOIN countries c ON c.id = s.country_id WHERE cs.collection_id = ? GROUP BY s.country_id]; nested exception is org.postgresql.util.PSQLException: ERROR: column "c.name_ru" must appear in the GROUP BY clause or be used in an aggregate function

@php-coder
Copy link
Owner

Failure 2: when user adds a series to the collection.
Failure 5: when user adds a series to the collection.

Both these cases were fixed by using id from a primary table. For example, instead of s.country_id we used c.id and likewise for categories table.

Thanks @asm0dey for the hint!

php-coder added a commit that referenced this issue Oct 27, 2019
…ng on PostgreSQL.

The error was:
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT
CASE WHEN 'ru' = ? THEN COALESCE(c.name_ru, c.name) ELSE c.name END AS name , SUM(s.quantity) AS
counter FROM collections_series cs JOIN series s ON s.id = cs.series_id JOIN categories c ON c.id =
s.category_id WHERE cs.collection_id = ? GROUP BY s.category_id]; nested exception is
org.postgresql.util.PSQLException: ERROR: column "c.name_ru" must appear in the GROUP BY clause or
be used in an aggregate function

Thanks to Pavel Finkelshtein <pavel.finkelshtein@gmail.com> for help to find a fix.

Part of #1140
php-coder added a commit that referenced this issue Oct 27, 2019
…g on PostgreSQL.

The error was:
org.springframework.jdbc.BadSqlGrammarException: PreparedStatementCallback; bad SQL grammar [SELECT
COALESCE(CASE WHEN 'ru' = ? THEN COALESCE(c.name_ru, c.name) ELSE c.name END, 'Unknown') AS name ,
SUM(s.quantity) AS counter FROM collections_series cs JOIN series s ON s.id = cs.series_id LEFT
JOIN countries c ON c.id = s.country_id WHERE cs.collection_id = ? GROUP BY s.country_id];
nested exception is org.postgresql.util.PSQLException: ERROR: column "c.name_ru" must appear in
the GROUP BY clause or be used in an aggregate function

Part of #1140
@php-coder php-coder pinned this issue Nov 17, 2019
@php-coder
Copy link
Owner

Failure 4: when user creates a series with Michel catalog numbers:

It seems like removing FROM dual helps. But I'm surprised that it works on MySQL given that I added that clause exactly for this database in order to fix incorrect syntax (see b2eb7d0).

@php-coder php-coder unpinned this issue Dec 1, 2019
php-coder added a commit that referenced this issue Dec 18, 2019
@php-coder
Copy link
Owner

/spent 52m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants