# Improving QueryNew(struct, data)

**URL:** <https://dev.lucee.org/t/improving-querynew-struct-data/2424>\
**Category:** proposals\
**Created:** [June 2, 2017, 2:54am UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424 "2017-06-02T02:54:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zackster](https://dev.lucee.org/user_avatar/dev.lucee.org/zackster/32/3484_2.png) [@Zackster](https://dev.lucee.org/u/Zackster)\
**Post date:** [June 2, 2017, 2:54am UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424/1 "2017-06-02T02:54:41Z")

</div>

the syntax for queryNew is a bit ugly and leads to hard to maintain code due to  
the need to maintaining two separate arrays or lists to specify columns and data types

being able to pass in a struct which defines the columns and datatype would be a lot  
clearer and easier to maintain

```auto
queryNew("name,age","varchar,numeric",[["Susi",20],["Urs",24]]); 

vs

queryNew({"name"="varchar","age"="numeric"},[["Susi",20],["Urs",24]]); 

```

> **[QueryNew() :: Lucee Documentation](https://docs.lucee.org/reference/functions/querynew.html)**
>
> Creates an empty query (query object).

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [June 2, 2017, 4:23pm UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424/2 "2017-06-02T16:23:34Z")

</div>

+1

---

<div class="post-metadata">

**Author:** ![micstriit](https://dev.lucee.org/user_avatar/dev.lucee.org/micstriit/32/26_2.png) [@micstriit](https://dev.lucee.org/u/micstriit)\
**Post date:** [June 2, 2017, 6:21pm UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424/3 "2017-06-02T18:21:19Z")

</div>

i personally never use queryNew to create a populated query, because it is to complicated.  
i use the function [query](http://docs.lucee.org/reference/functions/query.html) instead:  
`qry=query('lastname':['Sorglos','Chlous'],'firstname':['Susi','Sami']);`

When you are asking yourself why we have 2 functions doing the same in different ways, the answer is simple.  
Compatibility, we added _Query_ with Railo 1.0 long before _queryNew_ had this functionality, then when ACF added this functionality we had to follow.

I get your point, but i PERSONALLY see that function only as a must have and because of that not worth extending it beyond the ACF functionality. If you don’t care about compatibility to ACF, use _Query_.

---

<div class="post-metadata">

**Author:** ![mtbrown](https://dev.lucee.org/letter_avatar_proxy/v4/letter/m/9dc877/32.png) [@mtbrown](https://dev.lucee.org/u/mtbrown)\
**Post date:** [June 2, 2017, 7:34pm UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424/4 "2017-06-02T19:34:27Z")

</div>

> If you don’t care about compatibility to ACF, use Query.

Anyone looking to use the proposed new function signature would be breaking compatibility regardless. The documentation is unsurprisingly terrible for _query()_, though.

---

<div class="post-metadata">

**Author:** ![Zackster](https://dev.lucee.org/user_avatar/dev.lucee.org/zackster/32/3484_2.png) [@Zackster](https://dev.lucee.org/u/Zackster)\
**Post date:** [June 3, 2017, 12:12am UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424/5 "2017-06-03T00:12:18Z")

</div>

Oh, I wasn’t aware of query() and yes the docs are a shocker!

> **[Query() :: Lucee Documentation](https://docs.lucee.org/reference/functions/query.html)**
>
> Create and populate a query object in the form query(columnName1:\[1,2,3\],columnName2:\[4,5,6\])

Does the syntax for query() even allow specifying datatypes? It’s rather important for QoQs

Well,how about createQuery(struct, data) which is also more consistent with existing CFML functions

(aside, can anyone point to an example of how to reference other similar functions in the docs)

---

<div class="post-metadata">

**Author:** ![isapir](https://dev.lucee.org/user_avatar/dev.lucee.org/isapir/32/854_2.png) [@isapir](https://dev.lucee.org/u/isapir)\
**Post date:** [June 3, 2017, 5:24pm UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424/6 "2017-06-03T17:24:07Z")

</div>

> [@mtbrown](#):
>
> The documentation is unsurprisingly terrible for

The documentation is open-sourced at [GitHub - lucee/lucee-docs: Source and build scripts for Lucee's documentation.](https://github.com/lucee/lucee-docs/) . If you find something to be “unsurprisingly terrible” then please take a moment and help improve it.

Thank you.

---

<div class="post-metadata">

**Author:** ![markdrew](https://dev.lucee.org/user_avatar/dev.lucee.org/markdrew/32/78_2.png) [@markdrew](https://dev.lucee.org/u/markdrew)\
**Post date:** [June 3, 2017, 6:43pm UTC](https://dev.lucee.org/t/improving-querynew-struct-data/2424/7 "2017-06-03T18:43:20Z")

</div>

> [@21Solutions](#):
>
> The documentation is open-sourced at [GitHub - lucee/lucee-docs: Source and build scripts for Lucee's documentation.](https://github.com/lucee/lucee-docs/) . If you find something to be “unsurprisingly terrible” then please take a moment and help improve it.
> 
> Thank you.

There is literally no documentation for this tag. Which is especially bad if it has been in since Railo 1!

I have put a submission that hopefully helps a bit

> <https://github.com/lucee/lucee-docs/pull/250>
