Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
fix(introspection): mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
timsuchanek committed Mar 2, 2019
1 parent 33fd0d1 commit 386577e
Show file tree
Hide file tree
Showing 8 changed files with 30 additions and 59 deletions.
2 changes: 1 addition & 1 deletion cli/packages/prisma-cli-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
"lodash.differenceby": "^4.8.0",
"mongodb": "^3.1.10",
"multimatch": "^2.1.0",
"mysql2": "^1.6.5",
"mysql": "^2.16.0",
"node-forge": "^0.7.1",
"npm-run": "4.1.2",
"opn": "^5.1.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Client as PGClient } from 'pg'
import { MongoClient } from 'mongodb'
import { createConnection, Connection } from 'mysql2'
import { createConnection, Connection } from 'mysql'

import { DatabaseCredentials, EndpointDialog } from '../../utils/EndpointDialog'
import { omit } from 'lodash'
Expand Down
2 changes: 1 addition & 1 deletion cli/packages/prisma-db-introspection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"graphql-request": "^1.5.0",
"lodash": "^4.17.4",
"mongodb": "^3.1.10",
"mysql2": "^1.6.5",
"mysql": "^2.16.0",
"pg": "^7.4.1",
"pluralize": "^7.0.0",
"prisma-datamodel": "1.23.0-alpha.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as path from 'path'
import * as fs from 'fs'
import { DefaultParser, DefaultRenderer, DatabaseType } from 'prisma-datamodel'

import * as mysql from 'mysql2'
import * as mysql from 'mysql'
import { connectionDetails } from '../connectionDetails'
import { MysqlConnector } from '../../../../databases/relational/mysql/mysqlConnector'
import MysqlClient from '../../../../databases/relational/mysql/mysqlDatabaseClient'
Expand Down Expand Up @@ -80,7 +80,11 @@ export default async function blackBoxTest(name: string) {
const testNames = fs.readdirSync(relativeTestCaseDir)

for (const testName of testNames) {
test(`Introspects ${testName}/mysql correctly`, async () => {
await blackBoxTest(testName)
}, 20000)
test(
`Introspects ${testName}/mysql correctly`,
async () => {
await blackBoxTest(testName)
},
20000,
)
}
2 changes: 1 addition & 1 deletion cli/packages/prisma-db-introspection/src/connectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { MongoConnector } from './databases/document/mongo/mongoConnector'
import IDatabaseClient from './databases/IDatabaseClient'
import { MongoClient } from 'mongodb'
import { MysqlConnector } from './databases/relational/mysql/mysqlConnector'
import { Connection } from 'mysql2'
import { Connection } from 'mysql'
import { Client } from 'pg'

export default abstract class Connectors {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
IEnum,
ISequenceInfo,
} from '../relationalConnector'
import { Connection } from 'mysql2'
import { Connection } from 'mysql'
import { DatabaseType, camelCase } from 'prisma-datamodel'
import { MysqlIntrospectionResult } from './mysqlIntrospectionResult'
import { RelationalIntrospectionResult } from '../relationalIntrospectionResult'
Expand Down Expand Up @@ -127,7 +127,7 @@ export class MysqlConnector extends RelationalConnector {
AND table_schema = ?`

return (await this.query(enumQuery, [schemaName])).map(row => {
const enumValues = row.enumValues as string
const enumValues = row.column_type as string
// Strip 'enum(' from beginning and ')' from end.
const strippedEnumValues = enumValues.substring(5, enumValues.length - 1)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import IDatabaseClient from '../../IDatabaseClient'
import { Connection } from 'mysql2'
import { Connection } from 'mysql'

export default class MySqlDatabaseClient implements IDatabaseClient {
private client: Connection
Expand Down
63 changes: 15 additions & 48 deletions cli/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1321,6 +1321,11 @@ before-after-hook@^1.2.0:
resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-1.3.2.tgz#7bfbf844ad670aa7a96b5a4e4e15bd74b08ed66b"
integrity sha512-zyPgY5dgbf99c0uGUjhY4w+mxqEGxPKg9RQDl34VvrVh2bM31lFN+mwR1ZHepq/KA3VCPk1gwJZL6IIJqjLy2w==

bignumber.js@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-4.1.0.tgz#db6f14067c140bd46624815a7916c92d9b6c24b1"
integrity sha512-eJzYkFYy9L4JzXsbymsFn3p54D+llV27oTQ+ziJG7WFRheJcNZilgVXMG0LoZtlQSKBsJdWtLFqOD0u+U0jZKA==

bin-links@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/bin-links/-/bin-links-1.1.2.tgz#fb74bd54bae6b7befc6c6221f25322ac830d9757"
Expand Down Expand Up @@ -2549,11 +2554,6 @@ delegates@^1.0.0:
resolved "https://registry.yarnpkg.com/delegates/-/delegates-1.0.0.tgz#84c6e159b81904fdca59a0ef44cd870d31250f9a"
integrity sha1-hMbhWbgZBP3KWaDvRM2HDTElD5o=

denque@^1.4.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/denque/-/denque-1.4.0.tgz#79e2f0490195502107f24d9553f374837dabc916"
integrity sha512-gh513ac7aiKrAgjiIBWZG0EASyDF9p4JMWwKA8YU5s9figrL5SRNEMT6FDynsegakuhWd1wVqTvqvqAoDxw7wQ==

depd@~1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
Expand Down Expand Up @@ -3502,13 +3502,6 @@ gaze@^0.5.1:
dependencies:
globule "~0.1.0"

generate-function@^2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/generate-function/-/generate-function-2.3.1.tgz#f069617690c10c868e73b8465746764f97c3479f"
integrity sha512-eeB5GfMNeevm/GRYq20ShmsaGcmI81kIX2K9XQx5miC8KdHaC6Jm0qQ8ZNeGOi7wYB8OsdxKs+Y2oVuTFuVwKQ==
dependencies:
is-property "^1.0.2"

genfun@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/genfun/-/genfun-5.0.0.tgz#9dd9710a06900a5c4a5bf57aca5da4e52fe76537"
Expand Down Expand Up @@ -4543,11 +4536,6 @@ is-promise@^2.1.0:
resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"
integrity sha1-eaKp7OfwlugPNtKy87wWwf9L8/o=

is-property@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/is-property/-/is-property-1.0.2.tgz#57fe1c4e48474edd65b09911f26b1cd4095dda84"
integrity sha1-V/4cTkhHTt1lsJkR8msc1Ald2oQ=

is-redirect@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-redirect/-/is-redirect-1.0.0.tgz#1d03dded53bd8db0f30c26e4f95d36fc7c87dc24"
Expand Down Expand Up @@ -5849,11 +5837,6 @@ log-update@^2.3.0:
cli-cursor "^2.0.0"
wrap-ansi "^3.0.1"

long@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/long/-/long-4.0.0.tgz#9a7b71cfb7d361a194ea555241c92f7468d5bf28"
integrity sha512-XsP+KhQif4bjX1kbuSiySJFNAehNxgLb6hPRGJ9QsUr8ajHkuXGdrHmFUTUUXhDwVX2R5bY4JNZEwbUiMhV+MA==

loose-envify@^1.0.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf"
Expand Down Expand Up @@ -6388,26 +6371,15 @@ mute-stream@~0.0.4:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==

mysql2@^1.6.5:
version "1.6.5"
resolved "https://registry.yarnpkg.com/mysql2/-/mysql2-1.6.5.tgz#6695304fa2ce793dda5c98e8bbec65cbd2e6cb9d"
integrity sha512-zedaOOyb3msuuZcJJnxIX/EGOpmljDG7B+UevRH5lqcv+yhy9eCwkArBz8/AO+/rlY3/oCsOdG8R5oD6k0hNfg==
mysql@^2.16.0:
version "2.16.0"
resolved "https://registry.yarnpkg.com/mysql/-/mysql-2.16.0.tgz#b23b22ab5de44fc2d5d32bd4f5af6653fc45e2ba"
integrity sha512-dPbN2LHonQp7D5ja5DJXNbCLe/HRdu+f3v61aguzNRQIrmZLOeRoymBYyeThrR6ug+FqzDL95Gc9maqZUJS+Gw==
dependencies:
denque "^1.4.0"
generate-function "^2.3.1"
iconv-lite "^0.4.24"
long "^4.0.0"
lru-cache "^4.1.3"
named-placeholders "^1.1.2"
seq-queue "^0.0.5"
sqlstring "^2.3.1"

named-placeholders@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/named-placeholders/-/named-placeholders-1.1.2.tgz#ceb1fbff50b6b33492b5cf214ccf5e39cef3d0e8"
integrity sha512-wiFWqxoLL3PGVReSZpjLVxyJ1bRqe+KKJVbr4hGs1KWfTZTQyezHFBbuKj9hsizHyGV2ne7EMjHdxEGAybD5SA==
dependencies:
lru-cache "^4.1.3"
bignumber.js "4.1.0"
readable-stream "2.3.6"
safe-buffer "5.1.2"
sqlstring "2.3.1"

nan@^2.9.2:
version "2.12.1"
Expand Down Expand Up @@ -8023,7 +7995,7 @@ read@1, read@~1.0.1, read@~1.0.7:
dependencies:
mute-stream "~0.0.4"

"readable-stream@1 || 2", readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6:
"readable-stream@1 || 2", readable-stream@2.3.6, readable-stream@^2.0.0, readable-stream@^2.0.1, readable-stream@^2.0.2, readable-stream@^2.0.5, readable-stream@^2.0.6, readable-stream@^2.1.4, readable-stream@^2.1.5, readable-stream@^2.2.2, readable-stream@^2.3.0, readable-stream@^2.3.5, readable-stream@^2.3.6, readable-stream@~2.3.6:
version "2.3.6"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf"
integrity sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==
Expand Down Expand Up @@ -8546,11 +8518,6 @@ send@0.16.2:
range-parser "~1.2.0"
statuses "~1.4.0"

seq-queue@^0.0.5:
version "0.0.5"
resolved "https://registry.yarnpkg.com/seq-queue/-/seq-queue-0.0.5.tgz#d56812e1c017a6e4e7c3e3a37a1da6d78dd3c93e"
integrity sha1-1WgS4cAXpuTnw+Ojeh2m143TyT4=

serialize-error@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/serialize-error/-/serialize-error-2.1.0.tgz#50b679d5635cdf84667bdc8e59af4e5b81d5f60a"
Expand Down Expand Up @@ -8907,7 +8874,7 @@ sprintf-js@~1.0.2:
resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c"
integrity sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=

sqlstring@^2.3.1:
sqlstring@2.3.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/sqlstring/-/sqlstring-2.3.1.tgz#475393ff9e91479aea62dcaf0ca3d14983a7fb40"
integrity sha1-R1OT/56RR5rqYtyvDKPRSYOn+0A=
Expand Down

0 comments on commit 386577e

Please sign in to comment.