-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
PG: Support for multiple projection in aggregate #4469
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -723,15 +723,15 @@ export class PostgresStorageAdapter { | |
}); | ||
const qs = `CREATE TABLE IF NOT EXISTS $1:name (${patternsArray.join()})`; | ||
const values = [className, ...valuesArray]; | ||
|
||
return conn.task('create-table', function * (t) { | ||
try { | ||
yield self._ensureSchemaCollectionExists(t); | ||
yield t.none(qs, values); | ||
} catch(error) { | ||
if (error.code !== PostgresDuplicateRelationError) { | ||
throw error; | ||
} | ||
if (error.code !== PostgresDuplicateRelationError) { | ||
throw error; | ||
} | ||
// ELSE: Table already exists, must have been created by a different request. Ignore the error. | ||
} | ||
yield t.tx('create-table-tx', tx => { | ||
|
@@ -755,14 +755,14 @@ export class PostgresStorageAdapter { | |
postgresType: parseTypeToPostgresType(type) | ||
}); | ||
} catch(error) { | ||
if (error.code === PostgresRelationDoesNotExistError) { | ||
return yield self.createClass(className, {fields: {[fieldName]: type}}, t); | ||
} | ||
if (error.code !== PostgresDuplicateColumnError) { | ||
throw error; | ||
} | ||
// Column already exists, created by other request. Carry on to see if it's the right type. | ||
}; | ||
if (error.code === PostgresRelationDoesNotExistError) { | ||
return yield self.createClass(className, {fields: {[fieldName]: type}}, t); | ||
} | ||
if (error.code !== PostgresDuplicateColumnError) { | ||
throw error; | ||
} | ||
// Column already exists, created by other request. Carry on to see if it's the right type. | ||
} | ||
} else { | ||
yield t.none('CREATE TABLE IF NOT EXISTS $<joinTable:name> ("relatedId" varChar(120), "owningId" varChar(120), PRIMARY KEY("relatedId", "owningId") )', {joinTable: `_Join:${fieldName}:${className}`}); | ||
} | ||
|
@@ -794,7 +794,7 @@ export class PostgresStorageAdapter { | |
const now = new Date().getTime(); | ||
const helpers = this._pgp.helpers; | ||
debug('deleteAllClasses'); | ||
|
||
return this._client.task('delete-all-classes', function * (t) { | ||
try { | ||
const results = yield t.any('SELECT * FROM "_SCHEMA"'); | ||
|
@@ -811,8 +811,8 @@ export class PostgresStorageAdapter { | |
// No _SCHEMA collection. Don't delete anything. | ||
} | ||
}).then(() => { | ||
debug(`deleteAllClasses done in ${new Date().getTime() - now}`); | ||
}); | ||
debug(`deleteAllClasses done in ${new Date().getTime() - now}`); | ||
}); | ||
} | ||
|
||
// Remove the column and all the data. For Relations, the _Join collection is handled | ||
|
@@ -860,7 +860,7 @@ export class PostgresStorageAdapter { | |
return this._client.task('get-all-classes', function * (t) { | ||
yield self._ensureSchemaCollectionExists(t); | ||
return yield t.map('SELECT * FROM "_SCHEMA"', null, row => toParseSchema({ className: row.className, ...row.schema })); | ||
}); | ||
}); | ||
} | ||
|
||
// Return a promise for the schema with the given name, in Parse format. If | ||
|
@@ -1500,7 +1500,6 @@ export class PostgresStorageAdapter { | |
columns.push(`AVG(${transformAggregateField(value.$avg)}) AS "${field}"`); | ||
} | ||
} | ||
columns.join(); | ||
} else { | ||
columns.push('*'); | ||
} | ||
|
@@ -1546,7 +1545,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 commentThe reason will be displayed to describe this comment to others. Learn more. @vitaly-t Joined here |
||
debug(qs, values); | ||
return this._client.map(qs, values, a => this.postgresObjectToParseObject(className, a, schema)) | ||
.then(results => { | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Are you sure you do not need to join the column there? Or is it the default for ES6 template strings when it comes to arrays?
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.
Did I reject this? Sorry, I'm not quite sure what I'm doing when it comes to reviews :)
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.
No problem. I did join the columns here. They weren't joined before properly.