Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Feature Request: Clone Method for Chains #5

Closed
dominicbarnes opened this Issue · 4 comments

2 participants

@dominicbarnes

Just a small feature request for the API. I'd like a clone method that would take an existing chain and return a functional duplicate of the working SQL command.

My use-case is like this: I have a lib that's generating a SELECT statement for single items by ID, as well as the list of all in a collection. Having to specify my fields/tables/etc is kinda cumbersome and creating a wrapper function is not very elegant either.

For example:

var select = squel.select()
    .field("id")
    .field("name")
    .from("users", "u");

var single = select.clone()
    .where("id = ?")
    .toString();

var list = select.clone()
    .limit(10)
    .offset(0)
    .toString();

This is a trivial example, but after adding joins and other conditions, this becomes a much more friendly way to approach similar queries.

@hiddentao
Owner

This is a good idea. In the interim have you tried using normal cloning methods? http://stackoverflow.com/a/5344074

@dominicbarnes

I have not yet, I'll give it a spin and report back for other's reference.

@hiddentao hiddentao referenced this issue from a commit
@hiddentao All builders now have a clone() method.
Fixed test setup error whereby tests being run multiple times.

Simplified Makefile test file spec.

refs #5
04e47e8
@hiddentao
Owner

Latest version (1.0.5) now comes with a clone() method available to all query builders (but not Expression builders yet, unfortunately)

@dominicbarnes

Stellar, I'll just be using that then :)

Thanks!

@hiddentao hiddentao closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.