Giter VIP home page Giter VIP logo

Comments (6)

alexandru-slobodcicov avatar alexandru-slobodcicov commented on September 13, 2024

Could not reproduce. Could you please paste the json content as I cannot see the changeSet 1 applied in the logs? Suppose it was redacted. And it looks it failed at insertOne change.

from liquibase-mongodb.

szandany avatar szandany commented on September 13, 2024

Hi @alexandru-slobodcicov

Here is the changeLog
{ "databaseChangeLog": [ { "changeSet": { "id": "1", "author": "Alex", "comment": "Create person collection", "changes": [ { "createCollection": { "collectionName": "person", "options": { "$rawJson": { "validator": { "$jsonSchema": { "bsonType": "object", "required": [ "name", "address" ], "properties": { "name": { "bsonType": "string", "description": "The Name" }, "address": { "bsonType": ["string", "null"], "description": "The Address. Can accept nulls." }, "age": { "bsonType": "int", "description": "The Age" } } } }, "validationAction": "error", "validationLevel": "strict" } } } } ] } }, { "changeSet": { "id": "2", "author": "Nick", "comment": "Populate person table", "changes": [ { "insertOne": { "collectionName": "person", "document": { "$rawJson": { "name": "Alexandru Slobodcicov", "address": "Moldova" } } } }, { "insertMany": { "collectionName": "person", "documents": { "$rawJson": [ { "name": "Nicolas Bodros", "address": "Spain", "age": 34 }, { "name": "Luka Modrich", "address": null, "age": 55 } ] } } } ] } } ] }

The part it failed on is the insertMany change type.
...

"insertMany": { "collectionName": "person", "documents": { "$rawJson": [ { "name": "Nicolas Bodros", "address": "Spain", "age": 34 }, { "name": "Luka Modrich", "address": null, "age": 55 } ] } } }

...

from liquibase-mongodb.

alexandru-slobodcicov avatar alexandru-slobodcicov commented on September 13, 2024

Hi @szandany
Yes, indeed it fails at insertMany with java.lang.IllegalArgumentException: state should be: writes is not an empty list
It is because we got a insertOne, insertMany with empty document and respective documents fields.
insertOne passed as it can insert an empty document, insertMany couldn't because is not allowed to insert an empty Array of Document.

Could reproduce the same by misusing the $rawJson marker for example using the old marker $jsonPayload instead.
This could mean that you are using previous version of JsonNoSqlChangeLogParser which is still looking for $jsonPayload marker. you can confirm this by replacing $rawJson with $jsonPayload in your json example provided.

Please make sure you built the latest from main branch and have it in liquibase class path

from liquibase-mongodb.

szandany avatar szandany commented on September 13, 2024

Hi @alexandru-slobodcicov.
I tried your suggestion, but it didn't work. Can you please provide a fully tested new example that works in here? https://github.com/liquibase/liquibase-mongodb/blob/main/src/test/resources/liquibase/ext/json

Thank you so much!

from liquibase-mongodb.

alexandru-slobodcicov avatar alexandru-slobodcicov commented on September 13, 2024

Hi @szandany, your example is fine. It is something different hapenning. I suppose the original json parser was picked up, not mine implementation. You can check integration tests, all are passing. Will try to run as you do using liquibase command line. Suppose should be taken out the yaml .jar from lib. Will let you know the result

from liquibase-mongodb.

alexandru-slobodcicov avatar alexandru-slobodcicov commented on September 13, 2024

Hi @szandany In my logs I get:
[2020-11-07 13:08:54] INFO [liquibase.servicelocator] Cannot load service: liquibase.parser.ChangeLogParser: Provider liquibase.nosql.parser.json.JsonNoSqlChangeLogParser could not be instantiated
I can see in logs provided by you:
[2020-11-01 15:31:13] INFO [liquibase.servicelocator] Cannot load service: liquibase.parser.ChangeLogParser: liquibase.nosql.parser.json.JsonNoSqlChangeLogParser Unable to get public no-arg constructor
A bit different output however the root cause it is it cannot find jackson libraries in {liquibase_home}/lib
Mystery resolved, add to {liquibase_home}/lib:
jackson-annotations-2.11.3.jar
jackson-core-2.11.3.jar
jackson-databind-2.11.3.jar

I will relate a PR to this issue, just noticed dropAll not working by default from CLI

from liquibase-mongodb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.