spring-projects / spring-data-couchbase

Provides support to increase developer productivity in Java when using Couchbase. Uses familiar Spring concepts such as a template classes for core API usage and lightweight repository style data access.
https://spring.io/projects/spring-data-couchbase
Apache License 2.0
277 stars 191 forks source link

Should spring data couchbase handle list as JsonArray [DATACOUCH-337] #648

Closed spring-projects-issues closed 1 year ago

spring-projects-issues commented 7 years ago

Labusquiere opened DATACOUCH-337 and commented

I'm expecting :

@Query("#{#n1ql.selectEntity} WHERE (ANY v in externals SATISFIES v.codeSI in $ids END) AND #{#n1ql.filter}")
List<BouquetEntity> myQeury(@Param("ids") JsonArray ids);

generate the following :

SELECT META(`sekai`).id AS _ID, META(`sekai`).cas AS _CAS, `sekai`.* FROM `sekai` WHERE (ANY v in ids SATISFIES v.codeSI in ["value1","value2"] END) AND `_class` = \"ServicePlan::BouquetEntity\"

I did try with varargs, array and debug a bit and for me it s today impossible. Am I wrong? is there an other way to do it with @Query or it is not supported ?


Affects: 2.1.11 (Hopper SR11), 2.2.8 (Ingalls SR8), 3.0 GA (Kay)

spring-projects-issues commented 5 years ago

David Kelly commented

I did a simpler one:

@Query("#{#n1ql.selectEntity} where callsign In $callsigns")
List<Airport> findByCallsigns(JsonArray callsigns);

And this one works as I'd expect - the query generated looks like this (from trace logging):

2019-06-28 15:55:36,501 DEBUG .repository.query.AbstractN1qlBasedQuery: 151 - Executing N1QL query: {"statement":"SELECT META(`travel-sample`).id AS _ID, META(`travel-sample`).cas AS _CAS, `travel-sample`.* FROM `travel-sample` where callsign In $callsigns","$callsigns":["CITRUS","TXW"],"scan_consistency":"statement_plus"}

What was the query actually generated? I'm guessing I'm missing something, but JsonArray as a parameter seems to be working as expected for this simple thing I've done above

mikereiche commented 1 year ago

https://github.com/spring-projects/spring-data-couchbase/issues/1650 Added converters for JsonNode, JsonObject and JsonArray