Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
public
/
sequelize
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
不要怂,就是干,撸起袖子干!
Commit a91d8b68
authored
Dec 15, 2015
by
Sushant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
issue(5015) Added unit tests
1 parent
3774bebb
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
3 deletions
test/unit/sql/create-table.test.js
test/unit/sql/create-table.test.js
View file @
a91d8b6
...
...
@@ -5,19 +5,19 @@ var Support = require(__dirname + '/../support')
,
DataTypes
=
require
(
__dirname
+
'/../../../lib/data-types'
)
,
expectsql
=
Support
.
expectsql
,
current
=
Support
.
sequelize
,
sql
=
current
.
dialect
.
QueryGenerator
;
,
sql
=
current
.
dialect
.
QueryGenerator
,
_
=
require
(
'lodash'
);
describe
(
Support
.
getTestDialectTeaser
(
'SQL'
),
function
()
{
describe
(
'createTable'
,
function
()
{
describe
(
'with enums'
,
function
()
{
var
FooUser
=
current
.
define
(
'user'
,
{
mood
:
DataTypes
.
ENUM
(
'happy'
,
'sad'
)
},{
schema
:
'foo'
,
timestamps
:
false
});
describe
(
'with enums'
,
function
()
{
it
(
'references enum in the right schema #3171'
,
function
()
{
expectsql
(
sql
.
createTableQuery
(
FooUser
.
getTableName
(),
sql
.
attributesToSQL
(
FooUser
.
rawAttributes
),
{
}),
{
sqlite
:
'CREATE TABLE IF NOT EXISTS `foo.users` (`id` INTEGER PRIMARY KEY AUTOINCREMENT, `mood` TEXT);'
,
...
...
@@ -27,5 +27,29 @@ describe(Support.getTestDialectTeaser('SQL'), function() {
});
});
});
if
(
current
.
dialect
.
name
===
'postgres'
)
{
describe
(
'IF NOT EXISTS version check'
,
function
()
{
var
modifiedSQL
=
_
.
clone
(
sql
);
var
createTableQueryModified
=
sql
.
createTableQuery
.
bind
(
modifiedSQL
);
it
(
'it will not have IF NOT EXISTS for version 9.0 or below'
,
function
()
{
modifiedSQL
.
sequelize
.
options
.
databaseVersion
=
'9.0.0'
;
expectsql
(
createTableQueryModified
(
FooUser
.
getTableName
(),
sql
.
attributesToSQL
(
FooUser
.
rawAttributes
),
{
}),
{
postgres
:
'CREATE TABLE "foo"."users" ("id" SERIAL , "mood" "foo"."enum_users_mood", PRIMARY KEY ("id"));'
});
});
it
(
'it will have IF NOT EXISTS for version 9.1 or above'
,
function
()
{
modifiedSQL
.
sequelize
.
options
.
databaseVersion
=
'9.1.0'
;
expectsql
(
createTableQueryModified
(
FooUser
.
getTableName
(),
sql
.
attributesToSQL
(
FooUser
.
rawAttributes
),
{
}),
{
postgres
:
'CREATE TABLE IF NOT EXISTS "foo"."users" ("id" SERIAL , "mood" "foo"."enum_users_mood", PRIMARY KEY ("id"));'
});
});
it
(
'it will have IF NOT EXISTS for default version'
,
function
()
{
modifiedSQL
.
sequelize
.
options
.
databaseVersion
=
0
;
expectsql
(
createTableQueryModified
(
FooUser
.
getTableName
(),
sql
.
attributesToSQL
(
FooUser
.
rawAttributes
),
{
}),
{
postgres
:
'CREATE TABLE IF NOT EXISTS "foo"."users" ("id" SERIAL , "mood" "foo"."enum_users_mood", PRIMARY KEY ("id"));'
});
});
});
}
});
});
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment