Skip to content

Javascript error when generating Postgresql model #92

@neoneo

Description

@neoneo

When generating the model for Postgres, I get the following javascript error:

Uncaught ReferenceError: attribute is not defined
at eval (eval at sisulate ((index):5163), :21:23)
at Object.sisulate ((index):5206)
at HTMLLIElement.onclick ((index):6385)

This only happens when some attribute is historized. The model is generated fine without historized attributes. This is not an issue for SQLServer.

I'm running Chrome 56 on Mac, using the modeler on anchormodeling.com.

Is the Postgres modeler officially supported and maintained, or is it a community effort?
We are now looking into adopting Anchor Modeling, and SQLServer is not an option for us. I could look into it myself if you can give me some instruction.

The console logs: The script SQL/PostgreSQL/uni/CreateAnchorPerspectiveDifference.js could not be executed.

This is the string that could not be evaluated:

var anchor;

while (anchor = schema.nextAnchor()) {
    if(anchor.hasMoreAttributes()) { // only do perspectives if there are attributes
        if(anchor.hasMoreHistorizedAttributes()) {	
        	
_sisula_+="\n" +
"-- Difference perspective ---------------------------------------------------------------------------------------------\n" +
"-- d" + (anchor.name ? anchor.name : "") + " showing all differences between the given timepoints and optionally for a subset of attributes\n" +
"-----------------------------------------------------------------------------------------------------------------------\n" +
"CREATE OR REPLACE FUNCTION " + (anchor.capsule ? anchor.capsule : "") + "\.d" + (anchor.name ? anchor.name : "") + " (\n" +
"    intervalStart " + (schema.metadata.chronon ? schema.metadata.chronon : "") + ",\n" +
"    intervalEnd " + (schema.metadata.chronon ? schema.metadata.chronon : "") + ",\n" +
"    selection text = null\n" +
") RETURNS TABLE (\n" +
"    inspectedTimepoint " + (schema.metadata.chronon ? schema.metadata.chronon : "") + ",\n" +
"    mnemonic text,\n" +
"    " + (anchor.identityColumnName ? anchor.identityColumnName : "") + " " + (anchor.identity ? anchor.identity : "") + ",\n" +
"    " + (schema.METADATA ? "" + (anchor.metadataColumnName ? anchor.metadataColumnName : "") + " " + (schema.metadata.metadataType ? schema.metadata.metadataType : "") + "," : "") + "";
        	
    	while (attribute = anchor.nextAttribute()) {
_sisula_+="\n" +
"    " + (schema.IMPROVED ? "" + (attribute.anchorReferenceName ? attribute.anchorReferenceName : "") + " " + (anchor.identity ? anchor.identity : "") + "," : "") + "\n" +
"    " + (schema.METADATA ? "" + (attribute.metadataColumnName ? attribute.metadataColumnName : "") + " " + (schema.metadata.metadataType ? schema.metadata.metadataType : "") + "," : "") + "\n" +
"    " + (attribute.timeRange ? "" + (attribute.changingColumnName ? attribute.changingColumnName : "") + " " + (attribute.timeRange ? attribute.timeRange : "") + "," : "") + "\n" +
"    " + (attribute.isEquivalent() ? "" + (attribute.equivalentColumnName ? attribute.equivalentColumnName : "") + " " + (schema.metadata.equivalentRange ? schema.metadata.equivalentRange : "") + "," : "") + "\n" +
"";
    		if(attribute.isKnotted()) {
    			knot = attribute.knot;
_sisula_+="\n" +
"    " + (knot.hasChecksum() ? "" + (attribute.knotChecksumColumnName ? attribute.knotChecksumColumnName : "") + " bytea," : "") + "\n" +
"    " + (knot.isEquivalent() ? "" + (attribute.knotEquivalentColumnName ? attribute.knotEquivalentColumnName : "") + " " + (schema.metadata.equivalentRange ? schema.metadata.equivalentRange : "") + "," : "") + "\n" +
"    " + (attribute.knotValueColumnName ? attribute.knotValueColumnName : "") + " " + (knot.dataRange ? knot.dataRange : "") + ",\n" +
"    " + (schema.METADATA ? "" + (attribute.knotMetadataColumnName ? attribute.knotMetadataColumnName : "") + " " + (schema.metadata.metadataType ? schema.metadata.metadataType : "") + ", " : "") + "\n" +
"";
    		}
_sisula_+="\n" +
"    " + (attribute.hasChecksum() ? "" + (attribute.checksumColumnName ? attribute.checksumColumnName : "") + " bytea," : "") + "\n" +
"    " + (attribute.valueColumnName ? attribute.valueColumnName : "") + " " + (attribute.isKnotted() ? "" + (knot.identity ? knot.identity : "") + "" : "" + (attribute.dataRange ? attribute.dataRange : "") + "") + "";  
_sisula_+="" + (anchor.hasMoreAttributes() ? "," : "") + "\n" +
"";    	
    	}
_sisula_+="\n" +
") AS '\n" +
"SELECT\n" +
"    timepoints.inspectedTimepoint,\n" +
"    timepoints.mnemonic,\n" +
"    p" + (anchor.mnemonic ? anchor.mnemonic : "") + "\.*\n" +
"FROM (\n" +
"";
            while (attribute = anchor.nextHistorizedAttribute()) {
_sisula_+="\n" +
"    SELECT DISTINCT\n" +
"        " + (attribute.anchorReferenceName ? attribute.anchorReferenceName : "") + " AS " + (anchor.identityColumnName ? anchor.identityColumnName : "") + ",\n" +
"        CAST(" + (attribute.changingColumnName ? attribute.changingColumnName : "") + " AS " + (schema.metadata.chronon ? schema.metadata.chronon : "") + ") AS inspectedTimepoint,\n" +
"        ''" + (attribute.mnemonic ? attribute.mnemonic : "") + "'' AS mnemonic\n" +
"    FROM\n" +
"        " + (attribute.isEquivalent() ? "" + (attribute.capsule ? attribute.capsule : "") + "\.e" + (attribute.name ? attribute.name : "") + "(0) " : "" + (attribute.capsule ? attribute.capsule : "") + "\." + (attribute.name ? attribute.name : "") + "") + "\n" +
"    WHERE\n" +
"        (selection is null OR selection like ''%" + (attribute.mnemonic ? attribute.mnemonic : "") + "%'')\n" +
"    AND\n" +
"        " + (attribute.changingColumnName ? attribute.changingColumnName : "") + " BETWEEN intervalStart AND intervalEnd\n" +
"    " + (anchor.hasMoreHistorizedAttributes() ? "UNION" : "") + "\n" +
"";
            }
_sisula_+="\n" +
") timepoints\n" +
"CROSS JOIN LATERAL\n" +
"    " + (anchor.capsule ? anchor.capsule : "") + "\.p" + (anchor.name ? anchor.name : "") + "(timepoints.inspectedTimepoint) p" + (anchor.mnemonic ? anchor.mnemonic : "") + "\n" +
"WHERE\n" +
"    p" + (anchor.mnemonic ? anchor.mnemonic : "") + "\." + (anchor.identityColumnName ? anchor.identityColumnName : "") + " = timepoints." + (anchor.identityColumnName ? anchor.identityColumnName : "") + ";\n" +
"' LANGUAGE SQL;\n" +
"";
        }
    } // end of if anchor has any attributes
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions