[odb-users] Using query members while also renaming class members

Fabian Fritz fabianfuture at web.de
Sat Apr 21 12:34:17 EDT 2018


Unfortunately it didn't work:

// The class:
#pragma db object table("XPROCEDURE")
 class XProcedure {
private:
XVorgang() {}
friend class odb::access;
#pragma db id auto column("NR")
int nr;
#pragma db column("FILENAME")
std::string filename;
}

// The query:
result res(db->query<XProcedure>(query::nr > 5000000));

//The resulting SQL:
SELECT "XPROCEDURE"."NR", "XPROCEDURE"."FILENAME" FROM "XPROCEDURE"
WHERE "XPROCEDURE"."nr" > :1

And at that point my Oracle database complains because it doesn't know
any column nr (lower case).

2018-04-21 11:25 GMT+02:00 Fabian Fritz <fabianfuture at web.de>:
> Ah, I see. That should do the trick - thanks!
>
> 2018-04-21 10:57 GMT+02:00 Javier Gutierrez <javier.gutierrez at web.de>:
>> Itry with
>> #pragma db column("MYCOLUMN")
>> Instead of
>> #pragma db member("MYCOLUMN")
>>
>> ---- Fabian Fritz wrote ----
>>
>>
>> That's the thing though:
>>
>> If I put this above my class attributes
>> #pragma db member("MYCOLUMN")
>> int mycolumn
>>
>> The SELECT I get looks alright: SELECT "MYCOLUMN" FROM MYTABLE //...
>>
>> However when I use the query<MyClass>::mycolumn, I get WHERE "mycolumn" =
>> 123 //...
>> and that's where the database complains, because it doesn't know the column
>> in lowercase.
>>
>> So is it possible to map my class attributes to different column names while
>> still being able to use the query:: interface?
>>
>>
>> Thanks,
>> Fabian
>>
>> Javier Gutierrez <javier.gutierrez at web.de> schrieb am Do., 19. Apr. 2018,
>> 08:18:
>>>
>>> Hello there, try column("MYCOLUMN")
>>>
>>>
>>> -------- Original Message --------
>>> Subject: [odb-users] Using query members while also renaming class members
>>> From: Fabian Fritz <fabianfuture at web.de>
>>> To: odb-users at codesynthesis.com
>>> Date: 4/18/2018 9:16 PM
>>> > Hi,
>>> >
>>> > I have created a class MyClass from an existing table and used #pragma
>>> > db member("MYCOLUMN") above a member mycolumn, so I don't have to use
>>> > the uppercase name all the time. Now if I use
>>> > query<MyClass>::mycolumn, I get errors, because the query puts
>>> > "mycolumn" instead of MYCOLUMN in the sql.
>>> >
>>> > So my question is: can you use member("MYCOLUMN") to rename class
>>> > members (i.e. map them to the actual column names) while still using
>>> > the query interface?
>>> >
>>> > Thanks,
>>> > Fabian
>>> >
>>>
>>



More information about the odb-users mailing list