[odb-users] Null values for unset properties
Rafael Pena
pena.rd at gmail.com
Mon Jul 25 13:24:02 EDT 2011
I have a class as below. Is there anyway that I can keep the two optional
fields (double optionalValue, string optionalString) as null? If I don't set
the optionValue it defaults to 0 and optionalString defaults to "". I know
the queries can use is_null operator so I am guessing it can be changed
somehow. NOT NULL is the default type in ddl generated by ODB, can I change
the optional fields to #pragma db type("DOUBLE")? Is there a way to leave
unset fields as null?
#pragma db object
class File {
public:
File() {
}
File(const string& filename);
File(const File& orig);
virtual ~File();
//Setters and Getters
private:
friend class odb::access;
#pragma db id auto
unsigned long fileId;
//FileInformation
string filename;
string fileType;
ptime fileDate;
ptime converterStartdate;
ptime converterEndDate;
string loadingHost;
unsigned long fileSize;
#pragma db type("DOUBLE") // Can I do this?
double optionalValue;
string optionalString;
};
More information about the odb-users
mailing list