Ejemplo n.º 1
0
 // Shameless stolen from PostresqlSynchronizationFactory - davidleber
 //
 // I blame statementstToConvertColumnType for not taking a damn EOAttribute for
 // having to steal this from EOSQLExpression
 public String columnTypeStringForAttribute(EOAttribute attribute) {
   if (attribute.precision() != 0) {
     String precision = String.valueOf(attribute.precision());
     String scale = String.valueOf(attribute.scale());
     return _NSStringUtilities.concat(attribute.externalType(), "(", precision, ",", scale, ")");
   }
   if (attribute.width() != 0) {
     String width = String.valueOf(attribute.width());
     return _NSStringUtilities.concat(attribute.externalType(), "(", width, ")");
   }
   return attribute.externalType();
 }
Ejemplo n.º 2
0
    public EOSchemaSynchronizationColumnChanges objectStoreChangesFromAttributeToAttribute(
        EOAttribute schemaAttribute, EOAttribute modelAttribute) {
      EOSchemaSynchronizationColumnChanges objectStoreChanges =
          super.objectStoreChangesFromAttributeToAttribute(schemaAttribute, modelAttribute);
      if (objectStoreChanges.valueForKey("precision") != null
          || objectStoreChanges.valueForKey("scale") != null) {
        objectStoreChanges.clearPrecision();
        objectStoreChanges.clearScale();
      }
      if (!modelAttribute.externalType().equals(schemaAttribute.externalType())) {
        if (modelAttribute.externalType().equals("varchar")
            && schemaAttribute.externalType().equals("char"))
          objectStoreChanges.clearExternalType();
      } else {
        if (schemaAttribute.externalType().equals("object")
            && objectStoreChanges.valueForKey("width") != null) objectStoreChanges.clearWidth();
      }
      if ((modelAttribute.externalType().equals("char")
              || modelAttribute.externalType().equals("varchar"))
          && modelAttribute.width() == 1024
          && schemaAttribute.width() == 1023) objectStoreChanges.clearWidth();

      return objectStoreChanges;
    }