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

How to remove the value for used .field() #187

Open
figozhu opened this issue Nov 10, 2015 · 3 comments
Open

How to remove the value for used .field() #187

figozhu opened this issue Nov 10, 2015 · 3 comments

Comments

@figozhu
Copy link

figozhu commented Nov 10, 2015

var squel = require('squel');
var query = squel.select().from("foo").field("bar").field("xxx");
var sql = query.toString();

//if I want to only remove the "xxx" in field in runtime, how to do this?
query.remove_field("xxx"); // is squel support?
var sql2 = query.toString();

@abgivant
Copy link

This is something that would be helpful to me as well. Is this supported?

In the same vein, is there/could there be a way to remove all currently set fields? For instance, I have a paged query and want to count the total rows to be returned before it gets paged, so I'd like to replace all the currently selected fields with a single .field('count(1)'), but I don't see a way to do this.

@hiddentao
Copy link
Owner

This is not supported at the moment I'm afraid, although it wouldn't be hard to add. What you can currently do though is clone() a query builder prior to adding fields and then do a new query based off the clone.

@MartialSeron
Copy link

Almost 2 years later, this is still not supported.
I wanted it to be, so I forked the project and made a PR (#344).

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

No branches or pull requests

4 participants