/* * [PJYF Oct 19 2004] * This is a bad hack to get WO to create indes for external keys. * We use the primary key constrain generation to create our indexes. * But we need to be carefull not to overwrite previous constrains * */ protected boolean isSinglePrimaryKeyAttribute(EOAttribute attribute) { if (attribute == null) return false; EOEntity entity = (EOEntity) attribute.entity(); if ((entity == null) || entity.isAbstractEntity() || (entity.externalName() == null)) return false; NSArray primaryKeyAttributes = entity.primaryKeyAttributes(); if (primaryKeyAttributes.count() != 1) return false; return attribute.name().equals(((EOAttribute) primaryKeyAttributes.lastObject()).name()); }
@Override public NSArray<EOSQLExpression> statementsToInsertColumnForAttribute( EOAttribute attribute, EOSchemaGenerationOptions options) { String columnCreationClause = _columnCreationClauseForAttribute(attribute); return new NSArray<EOSQLExpression>( _expressionForString( (new StringBuilder()) .append("ALTER TABLE ") .append(attribute.entity().externalName()) .append(_alterPhraseInsertionClausePrefixAtIndex(0)) .append(columnCreationClause) .toString())); }
protected static void appendColumnForAttributeToStringBuilder( EOAttribute attribute, StringBuilder sb) { sb.append(attribute.entity().externalName()); sb.append('.'); sb.append(attribute.columnName()); }