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

Adds sequelize.literal() and sequelize.cast() #950

Merged
merged 3 commits into from Oct 14, 2013

Conversation

3 participants
@durango
Member

durango commented Oct 2, 2013

sequelize.literal() will tell Sequelize to not escape whatever you type
into the argument, for example:

sequelize.literal('1-2') will result in "1-2" unescaped.

sequelize.cast(input, type) will cast input into type, for example:

sequelize.cast('1-2', 'integer') will result in:

CAST('1-2' AS INTEGER)

Adds sequelize.literal() and sequelize.cast()
sequelize.literal() will tell Sequelize to not escape whatever you type
into the argument, for example:

sequelize.literal('1-2') will result in "1-2" unescaped.

sequelize.cast(input, type) will cast input into type, for example:

sequelize.cast('1-2', 'integer') will result in:

```CAST('1-2' AS INTEGER)```
@sdepold

This comment has been minimized.

Member

sdepold commented Oct 2, 2013

Awesome!

----- Ursprüngliche Nachricht -----
Von: "Daniel Durante" notifications@github.com
Gesendet: ‎03.‎10.‎2013 00:05
An: "sequelize/sequelize" sequelize@noreply.github.com
Betreff: [sequelize] Adds sequelize.literal() and sequelize.cast() (#950)

sequelize.literal() will tell Sequelize to not escape whatever you type
into the argument, for example:
sequelize.literal('1-2') will result in "1-2" unescaped.
sequelize.cast(input, type) will cast input into type, for example:
sequelize.cast('1-2', 'integer') will result in:
CAST('1-2' AS INTEGER)

You can merge this Pull Request by running
git pull https://github.com/durango/sequelize quickcastOr view, comment on, or merge it at:
#950
Commit Summary
Adds sequelize.literal() and sequelize.cast()
File Changes
M lib/dialects/abstract/query-generator.js (10)
M lib/sequelize.js (8)
M lib/utils.js (27)
M test/dao-factory.test.js (93)
Patch Links:
https://github.com/sequelize/sequelize/pull/950.patch
https://github.com/sequelize/sequelize/pull/950.diff

@durango

This comment has been minimized.

Member

durango commented Oct 3, 2013

@sdepold glad u like it :) everything works btw, travis is just being a real bitch lately and I have no idea why. We should consider looking into http://drone.io or some other alternative :/ I've been thinking about implementing a CI service myself.. a lot of the current ones use old methods for running processes (since things like Docker.io didn't exist) but lunching several isolated LXCs shouldn't be to hard O_o and much faster than travis =x unless travis is setting us on a very low priority due to "abuse" or a "fair use" policy :(

durango added some commits Oct 13, 2013

Merge branch 'master' into quickcast
Conflicts:
	lib/dialects/abstract/query-generator.js
@@ -279,7 +279,7 @@ module.exports = (function() {
return this.quoteIdentifiers(obj, force)
} else if (Array.isArray(obj)) {
return this.quote(obj[0], force) + ' ' + obj[1]
} else if (obj instanceof Utils.fn || obj instanceof Utils.col) {
} else if (obj instanceof Utils.fn || obj instanceof Utils.col || obj instanceof Utils.literal || obj instanceof Utils.cast) {

This comment has been minimized.

@janmeier

janmeier Oct 14, 2013

Member

This is where it would be nice to have some kind of 'superclass' concept in js, instead of checking for 4 different classes :)

Perhaps we could do a .internalRepresentationOfSomethingInSQL property in our 'special objects', instead of checking for instanceof?

This comment has been minimized.

@durango

durango Oct 14, 2013

Member

Tbh, we could just make another utils function like:

Utils.internalFn: function(obj) {
 return (.. || .. || ..);
}

It'll do the same thing just keep things nicer/tidier :) thoughts?

This comment has been minimized.

@janmeier

janmeier Oct 14, 2013

Member

Sounds good as well :)

mvh.
Jan Aagaard Meier
Tlf: 30 20 13 21

On Mon, Oct 14, 2013 at 11:58 PM, Daniel Durante
notifications@github.comwrote:

In lib/dialects/abstract/query-generator.js:

@@ -279,7 +279,7 @@ module.exports = (function() {
return this.quoteIdentifiers(obj, force)
} else if (Array.isArray(obj)) {
return this.quote(obj[0], force) + ' ' + obj[1]

  •  } else if (obj instanceof Utils.fn || obj instanceof Utils.col) {
    
  •  } else if (obj instanceof Utils.fn || obj instanceof Utils.col || obj instanceof Utils.literal || obj instanceof Utils.cast) {
    

Tbh, we could just make another utils function like:

Utils.internalFn: function(obj) {
return (.. || .. || ..);}

It'll do the same thing just keep things nicer/tidier :) thoughts?


Reply to this email directly or view it on GitHubhttps://github.com//pull/950/files#r6957127
.

@sdepold sdepold merged commit b0c58dc into sequelize:master Oct 14, 2013

1 check passed

default The Travis CI build passed
Details
@sdepold

This comment has been minimized.

Member

sdepold commented Oct 14, 2013

well done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment