Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Surround IDs with double quotes by default and back quotes for MySQL #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,7 @@ Thumbs.db

#OSX .DS_Store files
.DS_Store

# ignore IntelliJ IDEA project files
/.idea
*.iml
3 changes: 2 additions & 1 deletion DDLGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ define(function (require, exports, module) {
*/
DDLGenerator.prototype.getId = function (id, options) {
if (options.quoteIdentifiers) {
return "`" + id + "`";
var quote = options.dbms === "mysql" ? "`" : "\"";
return quote + id + quote;
}
return id;
};
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,18 @@ CREATE TABLE entity1 (
ALTER TABLE entity1 ADD FOREIGN KEY (fk1) REFERENCES entity2(col1);
```

* If `Quote Identifiers` option is selected, all identifiers will be surrounded by a backquote character.
* If `Quote Identifiers` option is selected, all identifiers will be surrounded by double quotes (or backquotes for MySQL).

(__Oracle__ selected in `DBMS` option)
```sql
CREATE TABLE "entity1" (
"col1" INTEGER,
"col2" VARCHAR(20),
...
);
```

(__MySQL__ selected in `DBMS` option)
```sql
CREATE TABLE `entity1` (
`col1` INTEGER,
Expand Down