void Constraint::setDeclInTableAttribute(void) { if(!isDeclaredInTable() || (constr_type==ConstraintType::foreign_key && !isAddedByLinking())) attributes[ParsersAttributes::DECL_IN_TABLE]=QString(); else if(!isReferRelationshipAddedColumn() || constr_type==ConstraintType::primary_key) attributes[ParsersAttributes::DECL_IN_TABLE]=ParsersAttributes::_TRUE_; }
QString Column::getCodeDefinition(unsigned def_type) { QString code_def=getCachedCode(def_type, false); if(!code_def.isEmpty()) return(code_def); if(getParentTable()) attributes[ParsersAttributes::TABLE]=getParentTable()->getName(true); attributes[ParsersAttributes::TYPE]=type.getCodeDefinition(def_type); attributes[ParsersAttributes::DEFAULT_VALUE]=QString(); if(!sequence) attributes[ParsersAttributes::DEFAULT_VALUE]=default_value; else { //Configuring the default value of the column to get the next value of the sequence if(def_type==SchemaParser::SQL_DEFINITION) attributes[ParsersAttributes::DEFAULT_VALUE]=QString("nextval('%1'::regclass)").arg(sequence->getSignature());//.remove("\"")); attributes[ParsersAttributes::SEQUENCE]=sequence->getName(true); } attributes[ParsersAttributes::NOT_NULL]=(!not_null ? QString() : ParsersAttributes::_TRUE_); attributes[ParsersAttributes::DECL_IN_TABLE]=(isDeclaredInTable() ? ParsersAttributes::_TRUE_ : QString()); return(BaseObject::__getCodeDefinition(def_type)); }
QString Column::getCodeDefinition(unsigned def_type) { if(getParentTable()) attributes[ParsersAttributes::TABLE]=getParentTable()->getName(true); attributes[ParsersAttributes::TYPE]=type.getCodeDefinition(def_type); attributes[ParsersAttributes::DEFAULT_VALUE]=default_value; attributes[ParsersAttributes::NOT_NULL]=(!not_null ? "" : "1"); attributes[ParsersAttributes::DECL_IN_TABLE]=(isDeclaredInTable() ? "1" : ""); return(BaseObject::__getCodeDefinition(def_type)); }