-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Introduces flow types for storage #4349
Conversation
@@ -78,20 +87,20 @@ const mongoSchemaFromFieldsAndClassNameAndCLP = (fields, className, classLevelPe | |||
} | |||
|
|||
|
|||
export class MongoStorageAdapter { | |||
export class MongoStorageAdapter implements StorageAdapter, IndexingStorageAdapter { | |||
// Private | |||
_uri: string; | |||
_collectionPrefix: string; | |||
_mongoOptions: Object; | |||
// Public | |||
connectionPromise; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it possible to add a type here or not worthwhile?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably yes,
Codecov Report
@@ Coverage Diff @@
## master #4349 +/- ##
==========================================
- Coverage 92.84% 92.79% -0.05%
==========================================
Files 118 118
Lines 8381 8372 -9
==========================================
- Hits 7781 7769 -12
- Misses 600 603 +3
Continue to review full report at Codecov.
|
@@ -1489,7 +1495,7 @@ export class PostgresStorageAdapter { | |||
} | |||
} | |||
|
|||
const qs = `SELECT ${columns} FROM $1:name ${wherePattern} ${sortPattern} ${limitPattern} ${skipPattern} ${groupPattern}`; | |||
const qs = `SELECT ${columns.join(',')} FROM $1:name ${wherePattern} ${sortPattern} ${limitPattern} ${skipPattern} ${groupPattern}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, how did the tests not catch this? Seems like this would have caused a noticeable problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah that's very very odd. @dplewis ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. There isn't a test for project
with multiple fields, only a test with 1 field. This should fix that issue.
@@ -117,75 +122,6 @@ const validateQuery = query => { | |||
}); | |||
} | |||
|
|||
function DatabaseController(adapter, schemaCache) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flovilmart could you fill me on the rationale for the changes in this file? There's a lot that's been shifted around in the diff and I'm not entirely sure what the objective is here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make it a class, and also make it conform to a particular interface, so it’s easier to know what’s consumed and how in the future (like the indexing) this also rationalizes to a certain extent also the interfaces for every calls to the adapters.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I see! Thanks for clarifying.
8d8f4c6
to
34a4d27
Compare
@montymxb I could go further, formalize Schema and SchemaController as it's quite tough to follow there what's what. What do you think? |
@flovilmart I think we could go further, but for now I think this is good for the PR 👍 . Any other improvements to structure are always good though. Just to note I recently took some time to go back through the source again for parse-server. Last time I really went through it all was when this was all first open sourced with fosco. A ton has changed since then, figured I needed to go back over it all. Looking at it all it's been really cool to see everything that's been built into this, but it's been a lot of growth. I think it could use some trimming/restructuring now to standardize and clean things up. In the process of doing that it would be nice to roadmap the layout that is parse server, in a general sense kind of like this for the php sdk but not necessarily in graphical form. Just something that we can add to the docs that can help someone grasp things like:
That's a lot of work to put together docs for stuff like that, but if we organize it so we do it with a general code cleanup/restructures we could do it piece by piece. Whenever we have time. Once the cleanup is done the documented portions of that code would be done as well (hopefully). Just some thoughts, we could open up a project for this to itemize what would need to be done. May not even need to actually do a code restructure either, maybe just cleanup some TODOs and such. Either way, it would be an excuse to make the project a bit more transparent and easy to understand. |
@@ -1627,7 +1633,7 @@ function literalizeRegexPart(s) { | |||
|
|||
// process regex that has a beginning specified for the literal text | |||
const matcher2 = /\\Q((?!\\E).*)$/ | |||
const result2 = s.match(matcher2); | |||
const result2: any = s.match(matcher2); | |||
if(result2 && result2.length > 1 && result2.index > -1){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the linter catch spaces in if statements. if () {
2d8ce40
to
37fd074
Compare
3f333b3
to
0c8180f
Compare
@flovilmart are we still pushing for this? |
Needs some rework |
spec/MongoStorageAdapter.spec.js
Outdated
@@ -1,6 +1,6 @@ | |||
'use strict'; | |||
|
|||
const MongoStorageAdapter = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter'); | |||
const MongoStorageAdapter = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter').MongoStorageAdapter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the newer airbnb wants:
const {MongoStorageAdapter} = require('../src/Adapters/Storage/Mongo/MongoStorageAdapter');
all the cool kids are doing it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lol :) most definitely :)
01f9da7
to
29bfacd
Compare
@flovilmart Do you know why |
Wanted to note that I've been keeping a small log of the arbitrary errors we see in CI. That one in particular is the most common from what I've observed. |
508fce7
to
d7b226e
Compare
- runs flow on pre tests - fixes flow
Fixing invalid database code in method `setIndexesWithSchemaFormat`: * It must be a transaction, not a task, as it executes multiple database changes * It should contain the initial queries inside the transaction, providing the context, not outside it; * Replaced the code with the ES6 Generator notation * Removing the use of batch, as the value of the result promise is irrelevant, only success/failure that matters
d7b226e
to
ef882d3
Compare
LGTM! Good work flo on getting flow types working. Let’s get this in before it gets stale. |
* Introduces flow types for storage * Better typing of QueryOptions * Adds flow types to SchemaCOntroller, - runs flow on pre tests - fixes flow * Adds ClassLevelPermissions type * Moves Controller types into a single file * Changes import styles * Changes import styles * fixing method setIndexesWithSchemaFormat (parse-community#4454) Fixing invalid database code in method `setIndexesWithSchemaFormat`: * It must be a transaction, not a task, as it executes multiple database changes * It should contain the initial queries inside the transaction, providing the context, not outside it; * Replaced the code with the ES6 Generator notation * Removing the use of batch, as the value of the result promise is irrelevant, only success/failure that matters * nits * Fixes tests, improves flow typing
No description provided.