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

Support jsonb data type with Postgres database #671

Merged
merged 19 commits into from
Oct 10, 2021

Conversation

pascalsem
Copy link
Contributor

@pascalsem pascalsem commented Mar 29, 2021

Hello,

In my organization we are using dbfit version 3.2.0 and added support to jsonb data type in order to enable data insertion on such table columns.

Made same modifications on this pull request than in 3.2.0 PostgresEnvironment class.

As I am not using Gradle, I cannot perform tests from my workstation .... and have been done with dbfit and a PostgreSQL 9.6.10 database. Sorry for that.

The test page looks like this (assuming connection is established with db) :

!|Execute|CREATE TABLE anything(field JSONB)|

!|Inspect Query|SELECT * FROM anything|

!|Insert |anything |
|field |
|!-{"field" : "value"}-!|

  • a parser for PGobject class

@javornikolov
Copy link
Contributor

Hi @pascalsem, thank you for this contribution! Are you able to add some tests - they will run automatically on CI server PostGres, you don't need PostgreSQL locally to run them.

@pascalsem
Copy link
Contributor Author

Hi @pascalsem, thank you for this contribution! Are you able to add some tests - they will run automatically on CI server PostGres, you don't need PostgreSQL locally to run them.

In progress :)

@pascalsem
Copy link
Contributor Author

pascalsem commented May 9, 2021

Hello @javornikolov I have updated pull request with missing components and tests to verify it works. It runs good in my local workstation (postgres 13.2 installed) but I can't figure out why it is failing in TravisCI. Is there any way for me to troubleshoot the execution ? Thanks :)

Ran ./gradlew :dbfit-java:postgres:integrationTest
intellij

@javornikolov
Copy link
Contributor

Hi @pascalsem, maybe that from Travis CI build log would be helpful enough:

> Task :dbfit-java:postgres:checkstyleTest FAILED
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PGobjectParseDelegateTest.java:3:8: Unused import - org.junit.Assert. [UnusedImports]
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PGobjectParseDelegateTest.java:7:8: Unused import - java.sql.SQLException. [UnusedImports]
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PostgresPGobjectNormaliserTest.java:3:8: Unused import - dbfit.util.TypeTransformer. [UnusedImports]
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PostgresPGobjectNormaliserTest.java:4:8: Unused import - org.junit.Assert. [UnusedImports]

@pascalsem
Copy link
Contributor Author

Hi @pascalsem, maybe that from Travis CI build log would be helpful enough:

> Task :dbfit-java:postgres:checkstyleTest FAILED
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PGobjectParseDelegateTest.java:3:8: Unused import - org.junit.Assert. [UnusedImports]
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PGobjectParseDelegateTest.java:7:8: Unused import - java.sql.SQLException. [UnusedImports]
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PostgresPGobjectNormaliserTest.java:3:8: Unused import - dbfit.util.TypeTransformer. [UnusedImports]
[ant:checkstyle] [ERROR] /home/travis/build/dbfit/dbfit/dbfit-java/postgres/src/test/java/dbfit/environment/PostgresPGobjectNormaliserTest.java:4:8: Unused import - org.junit.Assert. [UnusedImports]

Perfect, thanks a lot I will be fixing those and run the task :)

@pascalsem
Copy link
Contributor Author

pascalsem commented May 9, 2021

Hello again @javornikolov, I think I figured out why build is failing on Travis and not in local. Json data types in postgresql appeared since 9.2 but properly supported in 9.4 (https://www.postgresql.org/docs/9.4/datatype-json.html).

So, do you think we can afford to upgrade version of postgresql to at least 9.4 ? It seems I could try with this documentation https://docs.travis-ci.com/user/database-setup/

Update : changed travis postgresql engine to 9.6

import dbfit.util.Direction;
import dbfit.util.NameNormaliser;
import dbfit.util.DatabaseObjectName;
import dbfit.util.*;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We better use explicit imports

@javornikolov javornikolov added this to the 4.0.0 milestone Oct 10, 2021
@javornikolov javornikolov merged commit 6821992 into dbfit:master Oct 10, 2021
@MMatten
Copy link
Contributor

MMatten commented Oct 10, 2021

@javornikolov let me know if you think it's worth squashing some of these commits.

@javornikolov
Copy link
Contributor

Thanks, @MMatten, I already merged it keeping the original commits.

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

Successfully merging this pull request may close these issues.

None yet

3 participants