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

Fix updateAll and deleteAll implementations in all connectors #1167

Closed
8 tasks done
bajtos opened this issue Mar 4, 2015 · 36 comments
Closed
8 tasks done

Fix updateAll and deleteAll implementations in all connectors #1167

bajtos opened this issue Mar 4, 2015 · 36 comments
Assignees
Labels

Comments

@bajtos
Copy link
Member

bajtos commented Mar 4, 2015

  • 1. Add a test to juggler's test suite run by all connectors to check that updateAll is implemented and return the number of updated records.
  • 2. Fix Memory connector to provide the number of updated records
  • 3. Run the new test in all DB connectors and fix any test failures
    • Verify and fix MongoDB connector changes
    • Verify and fix MySQL connector changes
    • Verify and fix PostgreSQL connector changes
    • Verify and fix MSSQL connector changes
    • Verify and fix Oracle connector changes
@chandadharap
Copy link

Prioritize these connectors:
Mongo, Mysql, Postgress, MSSQL, Oracle

@superkhau
Copy link
Contributor

@bajtos Should I write unit tests for each connector individually? ie) Add two more unit tests directly toloopback-connector-mongodb? One that verifies updateAll is implemented` and another to verify a count is returned when updating records?

@bajtos
Copy link
Member Author

bajtos commented Mar 12, 2015

For number 3, should I write unit tests for each connector individually?

No, add your new tests to test/manipulation.test.js. This file is run by all connectors as part of their test suite (or at least it should be) via test/common.batch.js.

@bajtos
Copy link
Member Author

bajtos commented Mar 12, 2015

See also https://github.com/strongloop/loopback-datasource-juggler/blob/274a5c778ae0e76403fbb1480c7b144b898c3e18/test/memory.test.js#L404-L427, I am not sure if dao.js provides a fallback implementation for connectors that don't implement updateAll. If it does, then we should test it too.

@bajtos
Copy link
Member Author

bajtos commented Mar 12, 2015

It's ok to add the new tests to test/basic-querying.test.js as you did in loopbackio/loopback-datasource-juggler#502, considering that other updateAll tests are already living there.

@superkhau
Copy link
Contributor

@bajtos After speaking with @raymondfeng on hangouts, it was decided that we can just modify the second argument (get rid of data.rows) which allows me to use the second arg for all connectors. I am going to modify all the third arg updates to do that instead.

@bajtos
Copy link
Member Author

bajtos commented Mar 24, 2015

After speaking with @raymondfeng on hangouts, it was decided that we can just modify the second argument (get rid of data.rows) which allows me to use the second arg for all connectors. I am going to modify all the third arg updates to do that instead.

I am not convinced this is not a BC, but I'll go with whatever decision you have made so that we can get this finished ASAP.

@superkhau
Copy link
Contributor

@bajtos Had another meeting with @raymondfeng explaining the BC issue you just mentioned. Gonna update the PostgreSQL connector to return data.rows if selecting and {count: affectedRows} on destroyAll/updateAll. We can discuss any further changes directly there.

@bajtos
Copy link
Member Author

bajtos commented Mar 26, 2015

@superkhau could you please describe the callback arguments in the documentation explaining how to build a connector? http://docs.strongloop.com/display/LB/Building+a+connector

I am not sure if the API documentation in juggler's lib/dao.js was updated to match the changes we made to update* and delete* callbacks, could you please check that too?

@bajtos
Copy link
Member Author

bajtos commented Mar 26, 2015

@superkhau for example, updateAll still says that a scalar "count" value is returned: https://github.com/strongloop/loopback-datasource-juggler/blob/e13c0cdc12467aff5f347fa1112c03ba1dcdbb8b/lib/dao.js#L1634 It would be nice to fix the implementation too, it's using a property called count instead of info now.

What is the final loopback/juggler API that you have arrived at with @raymondfeng? Is the description below correct?

MyModel.updateAll -> cb(null, { count: X });
MyModel.deleteAll -> cb(null, { count: X });

@bajtos bajtos changed the title Fix updateAll implementation in all connectors Fix updateAll and deleteAll implementations in all connectors Mar 26, 2015
bajtos pushed a commit that referenced this issue Mar 26, 2015
@bajtos bajtos assigned bajtos and unassigned superkhau Mar 26, 2015
@bajtos
Copy link
Member Author

bajtos commented Mar 26, 2015

I am not sure if the API documentation in juggler's lib/dao.js was updated to match the changes we made to update* and delete* callbacks, could you please check that too?

I made the changes myself, see loopbackio/loopback-datasource-juggler#540 and #1252

@superkhau
Copy link
Contributor

@superkhau could you please describe the callback arguments in the documentation explaining how to build a connector? http://docs.strongloop.com/display/LB/Building+a+connector

Done.

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

No branches or pull requests

4 participants