-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
83 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 |
---|---|---|
|
@@ -179,7 +179,10 @@ describe('Database Connection', () => { | |
]); | ||
}); | ||
|
||
test('Add table column', async () => { | ||
test('Add and drop table column', async () => { | ||
// Skip Mongodb because it does not have schema | ||
if (process.env.CONNECTION_TYPE === 'mongodb') return; | ||
|
||
const { error } = await db.addColumn( | ||
DEFAULT_SCHEMA, | ||
'persons', | ||
|
@@ -194,40 +197,42 @@ describe('Database Connection', () => { | |
|
||
expect(error).not.toBeTruthy(); | ||
|
||
// Need to update email because MongoDB does not have schema | ||
if (process.env.CONNECTION_TYPE === 'bigquery') { | ||
await db.raw( | ||
`UPDATE \`${DEFAULT_SCHEMA}.persons\` SET email = '[email protected]' WHERE TRUE;` | ||
); | ||
} else { | ||
await db.update( | ||
DEFAULT_SCHEMA, | ||
'persons', | ||
{ | ||
email: '[email protected]', | ||
}, | ||
{} | ||
); | ||
} | ||
|
||
const { data } = await db.select(DEFAULT_SCHEMA, 'persons', { | ||
orderBy: ['id'], | ||
limit: 1000, | ||
offset: 0, | ||
}); | ||
|
||
expect(cleanup(data)).toEqual([ | ||
{ | ||
id: 1, | ||
full_name: 'Visal In', | ||
age: 25, | ||
email: '[email protected]', | ||
email: null, | ||
}, | ||
{ | ||
id: 2, | ||
full_name: 'Outerbase', | ||
age: 30, | ||
email: null, | ||
}, | ||
]); | ||
|
||
// Remove the column | ||
await db.dropColumn(DEFAULT_SCHEMA, 'persons', 'email'); | ||
|
||
const { data: data2 } = await db.select(DEFAULT_SCHEMA, 'persons', { | ||
orderBy: ['id'], | ||
}); | ||
|
||
expect(cleanup(data2)).toEqual([ | ||
{ | ||
id: 1, | ||
full_name: 'Visal In', | ||
age: 25, | ||
}, | ||
{ | ||
id: 2, | ||
full_name: 'Outerbase', | ||
age: 30, | ||
email: '[email protected]', | ||
}, | ||
]); | ||
}); | ||
|
@@ -264,7 +269,6 @@ describe('Database Connection', () => { | |
id: 2, | ||
full_name: 'Outerbase', | ||
age: 30, | ||
email: '[email protected]', | ||
}, | ||
]); | ||
}); | ||
|