0.14.14: Misc bugfixes in migrations & AsyncCollection keys
continuous-integration/drone/tag Build is failing Details
continuous-integration/drone/push Build is passing Details

master 0.14.14
Garrett Mills 6 months ago
parent 9a55623370
commit ac6fd0ef1d

@ -1,6 +1,6 @@
{
"name": "@extollo/lib",
"version": "0.14.13",
"version": "0.14.14",
"description": "The framework library that lifts up your code.",
"main": "lib/index.js",
"types": "lib/index.d.ts",

@ -92,5 +92,8 @@ export class CoreIDLoginProvider extends OAuth2LoginProvider<OAuth2LoginProvider
user.email = data.email
user.tagline = data.tagline
user.photoUrl = data.profile_photo
if ( typeof user.save === 'function' ) {
user.save()
}
}
}

@ -544,7 +544,7 @@ export class PostgreSQLDialect extends SQLDialect {
return parts.join('\n')
}
public renderAlterTable(builder: TableBuilder): string {
public renderAlterTable(builder: TableBuilder): Maybe<string> {
const alters: string[] = []
const columns = builder.getColumns()
@ -628,6 +628,10 @@ export class PostgreSQLDialect extends SQLDialect {
alters.push(` RENAME TO "${builder.getRename()}"`)
}
if ( !alters.length ) {
return undefined
}
return 'ALTER TABLE ' + builder.name + '\n' + alters.join(',\n')
}

@ -2,7 +2,7 @@ import {Constraint, QuerySource} from '../types'
import {AbstractBuilder} from '../builder/AbstractBuilder'
import {AppClass} from '../../lifecycle/AppClass'
import {ColumnBuilder, IndexBuilder, TableBuilder} from '../schema/TableBuilder'
import {Collectable, Collection} from '../../util'
import {Collectable, Collection, Maybe} from '../../util'
/** A scalar value which can be interpolated safely into an SQL query. */
export type ScalarEscapeValue = null | undefined | string | number | boolean | Date | QuerySafeValue;
@ -198,7 +198,7 @@ export abstract class SQLDialect extends AppClass {
* Given a table schema-builder, render an `ALTER TABLE...` query.
* @param builder
*/
public abstract renderAlterTable(builder: TableBuilder): string;
public abstract renderAlterTable(builder: TableBuilder): Maybe<string>;
/**
* Given a table schema-builder, render a `DROP TABLE...` query.
@ -314,7 +314,10 @@ export abstract class SQLDialect extends AppClass {
if ( !builder.isExisting() && builder.isDirty() ) {
parts.push(this.renderCreateTable(builder))
} else if ( builder.isExisting() && builder.isDirty() ) {
parts.push(this.renderAlterTable(builder))
const alterTable = this.renderAlterTable(builder)
if ( alterTable ) {
parts.push(alterTable)
}
}
// Render the various schema queries as a single transaction

@ -223,7 +223,16 @@ export class ColumnBuilder extends SchemaBuilderBase {
* @param type
*/
public type(type: FieldType): this {
if ( this.targetType === type ) {
if (
this.targetType === type
|| (
this.existsInSchema
&& (
(this.targetType === FieldType.integer && type === FieldType.serial)
|| (this.targetType === FieldType.bigint && type === FieldType.bigserial)
)
)
) {
return this
}

@ -43,7 +43,8 @@ export class AsyncCollection<T> {
if ( typeof key !== 'function' ) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
key = x => x[key]
await callback(items.map(x => x[key]))
return
}
await callback(items.map(key))
@ -56,7 +57,9 @@ export class AsyncCollection<T> {
if ( typeof key !== 'function' ) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
key = x => x[key]
await callback(items.map(x => x[key]).map(x => Number(x))
.all())
return
}
await callback(items.map(key).map(x => Number(x))

Loading…
Cancel
Save