Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Now custom value handler receives as a second argument hash of options a... #119

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Now custom value handler receives as a second argument hash of options a... #119

wants to merge 1 commit into from

Conversation

alekbarszczewski
Copy link

...nd it is possible to set options.dontQuote inside that handler which will prevent quoting value returned from it.
For example:

class SqlDefault
squel.registerValueHandler SqlDefault, (val, options) ->
  options.dontQuote = true
  'DEFAULT'

…s and it is possible to set options.dontQuote inside that handler which will prevent quoting value returned from it
@hiddentao
Copy link
Owner

There's a problem with this in that it may affect subsequent values which get formatted (since you're modifying the formatting options object directly and since objects are passed by-reference in JS). However I like the idea of passing further formatting options to the custom value handler so I'll leave those open - I'll probably incorporate this idea in the final fix.

@alekbarszczewski
Copy link
Author

Cool, so I am looking forward for it. Thanks.

@hiddentao
Copy link
Owner

I'm currently working through the backlog of issues so make take a few
weeks, but will get to it :)

On 19/01/2015 16:43, alekbarszczewski wrote:

Cool, so I am looking forward for it. Thanks.


Reply to this email directly or view it on GitHub
#119 (comment).

Ramesh Nair

Freelance Web Developer

www.hiddentao.com
www.github.com/hiddentao

@marklagendijk
Copy link

When this is implemented it would be useful to expose format and escape functionality to the valueHandlers. This way you could for example create a valueHandler like this:

function myValueHandler(value, options, escape, format){
  options.dontQuote = true
  return 'CAST(' + format(value.toString()) + ') as MyType';
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants