QString Index::getCodeDefinition(unsigned tipo_def) { setIndexElementsAttribute(tipo_def); attributes[ParsersAttributes::UNIQUE]=(index_attribs[UNIQUE] ? "1" : ""); attributes[ParsersAttributes::CONCURRENT]=(index_attribs[CONCURRENT] ? "1" : ""); attributes[ParsersAttributes::INDEX_TYPE]=(~indexing_type); attributes[ParsersAttributes::CONDITION]=conditional_expr; attributes[ParsersAttributes::STORAGE_PARAMS]=""; if(getParentTable()) { attributes[ParsersAttributes::TABLE]=getParentTable()->getName(true); if(tipo_def==SchemaParser::SQL_DEFINITION && getParentTable()->getSchema()) attributes[ParsersAttributes::SCHEMA]=getParentTable()->getSchema()->getName(true); } if(this->indexing_type==IndexingType::gin) attributes[ParsersAttributes::STORAGE_PARAMS]=attributes[ParsersAttributes::FAST_UPDATE]=(index_attribs[FAST_UPDATE] ? "1" : ""); if(this->indexing_type==IndexingType::btree && fill_factor >= 10) { attributes[ParsersAttributes::FACTOR]=QString("%1").arg(fill_factor); attributes[ParsersAttributes::STORAGE_PARAMS]="1"; } else if(tipo_def==SchemaParser::XML_DEFINITION) attributes[ParsersAttributes::FACTOR]="0"; /* Case the index doesn't referece some column added by relationship it will be declared inside the parent table construction by the use of 'decl-in-table' schema attribute */ if(!isReferRelationshipAddedColumn()) attributes[ParsersAttributes::DECL_IN_TABLE]="1"; return(BaseObject::__getCodeDefinition(tipo_def)); }
QString Trigger::getCodeDefinition(unsigned def_type) { setBasicAttributes(def_type); /* Case the trigger doesn't referece some column added by relationship it will be declared inside the parent table construction by the use of 'decl-in-table' schema attribute */ if(!isReferRelationshipAddedColumn()) attributes[ParsersAttributes::DECL_IN_TABLE]="1"; if(getParentTable()) attributes[ParsersAttributes::TABLE]=getParentTable()->getName(true); attributes[ParsersAttributes::CONSTRAINT]=(is_constraint ? "1" : ""); attributes[ParsersAttributes::FIRING_TYPE]=(~firing_type); //** Constraint trigger MUST execute per row ** attributes[ParsersAttributes::PER_ROW]=((is_exec_per_row && !is_constraint) || is_constraint ? "1" : ""); attributes[ParsersAttributes::CONDITION]=condition; if(referenced_table) { attributes[ParsersAttributes::REF_TABLE]=referenced_table->getName(true); attributes[ParsersAttributes::DEFERRABLE]=(is_deferrable ? "1" : ""); attributes[ParsersAttributes::DEFER_TYPE]=(~deferral_type); } return(BaseObject::__getCodeDefinition(def_type)); }
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 Index::getCodeDefinition(unsigned tipo_def) { setElementsAttribute(tipo_def); attributes[ParsersAttributes::UNIQUE]=(index_attribs[UNIQUE] ? "1" : ""); attributes[ParsersAttributes::CONCURRENT]=(index_attribs[CONCURRENT] ? "1" : ""); attributes[ParsersAttributes::FAST_UPDATE]=(index_attribs[FAST_UPDATE] ? "1" : ""); attributes[ParsersAttributes::INDEX_TYPE]=(~indexing_type); attributes[ParsersAttributes::CONDITION]=conditional_expr; if(this->parent_table) attributes[ParsersAttributes::TABLE]=this->parent_table->getName(true); attributes[ParsersAttributes::FACTOR]=QString("%1").arg(fill_factor); /* Case the index doesn't referece some column added by relationship it will be declared inside the parent table construction by the use of 'decl-in-table' schema attribute */ if(!isReferRelationshipAddedColumn()) attributes[ParsersAttributes::DECL_IN_TABLE]="1"; return(BaseObject::__getCodeDefinition(tipo_def)); }