ravendb / ravendb-go-client

MIT License
39 stars 16 forks source link

q = q.OrderBy("*** as double") #166

Closed bobmcallan closed 3 years ago

bobmcallan commented 3 years ago

Orderby as a double results in string.

eg. q = q.OrderBy("user_id as double") => "from Users order by 'user_id as double', last_name, first_name"

Bob

ayende commented 3 years ago

You need to use OrderByWithOrdering("user_id", "double"), instead.

ayende commented 3 years ago

see: https://github.com/ravendb/ravendb-go-client/blob/f43327b57a88ab5931012a163c340f6e5856b602/document_query.go#L569

bobmcallan commented 3 years ago

Thanks, however implemented as suggested :

q = q.OrderByWithOrdering("user_id", "double") q = q.AddOrder("last_name", false) q = q.AddOrder("first_name", false)

result: from Users order by user_id, last_name, first_name

Bob

bobmcallan commented 3 years ago

Worked it out.. CAPS for DOUBLE

package ravendb

type OrderingType = string

const ( OrderingTypeString = "STRING" OrderingTypeLong = "LONG" OrderingTypeDouble = "DOUBLE" OrderingTypeAlphaNumeric = "ALPHA_NUMERIC" )

Thanks, Bob