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 a79773dc
authored
Apr 26, 2011
by
Sascha Depold
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
freezeTableNames for getting tablenames as passed
1 parent
f0f55ae0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
1 deletions
lib/sequelize/model-definition.js
test/Sequelize/define.js
lib/sequelize/model-definition.js
View file @
a79773d
...
...
@@ -9,7 +9,7 @@ var ModelDefinition = module.exports = function(name, attributes, options) {
this
.
options
=
options
||
{}
this
.
options
.
timestamps
=
this
.
options
.
hasOwnProperty
(
'timestamps'
)
?
this
.
options
.
timestamps
:
true
this
.
name
=
name
this
.
tableName
=
Utils
.
pluralize
(
name
)
this
.
tableName
=
this
.
options
.
freezeTableName
?
name
:
Utils
.
pluralize
(
name
)
this
.
attributes
=
Utils
.
simplifyAttributes
(
attributes
)
this
.
modelManager
=
null
// defined by model-manager during addModel
this
.
associations
=
{}
...
...
test/Sequelize/define.js
View file @
a79773d
...
...
@@ -54,5 +54,13 @@ module.exports = {
'timestamp columns should be underscored if underscored is passed'
:
function
()
{
var
User
=
sequelize
.
define
(
'User'
+
parseInt
(
Math
.
random
()
*
999999999
),
{},
{
paranoid
:
true
,
underscored
:
true
})
assert
.
eql
(
User
.
attributes
,
{
id
:
"INT NOT NULL auto_increment PRIMARY KEY"
,
deleted_at
:
"DATETIME"
,
updated_at
:
"DATETIME NOT NULL"
,
created_at
:
"DATETIME NOT NULL"
})
},
'tablenames should be as passed if they are frozen'
:
function
()
{
var
User
=
sequelize
.
define
(
'User'
,
{},
{
freezeTableName
:
true
})
assert
.
eql
(
User
.
tableName
,
'User'
)
},
'tablenames should be pluralized if they are not frozen'
:
function
()
{
var
User
=
sequelize
.
define
(
'User'
,
{},
{
freezeTableName
:
false
})
assert
.
eql
(
User
.
tableName
,
'Users'
)
}
}
\ No newline at end of file
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