Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cfsqltype support to transfer.xml for when data types are not enough #10

Open
ghidinelli opened this issue Nov 20, 2014 · 1 comment

Comments

@ghidinelli
Copy link

Quick story - trying to add BigInt into my app that uses Transfer on Postgres. Transfer universally uses cf_sql_float for all "numeric" types. This breaks bigint support. It's possible to add addtional metadata into transfer.xml and have it flow to the right place but I gave up on bigint support for other reasons. This is how you would do it if you wanted to support more exotic data types/matching.

I'm only concerned with at this point however this could be extended:

  1. Fix the XSD to allow an additional attribute on properties called "sqltype"
  2. In property.cfc, add methods get/setSqlType(), add setSqlType("") to init(), in setMemento(), add:
        if(StructKeyExists(arguments.memento, "sqlType"))
        {
            setSqlType(arguments.memento.sqltype);
        }
  1. In transfer/com/sql/Query.cfc, add a third parameter to mapParam for "sqltype"
  2. In transfer/com/sql/QueryExecution.cfc, in executeQuery(), add a check for block.mapparam.sqltype and branch accordingly for your native use. In my case, I used cf_sql_bigint if sqltype was "bigint"
  3. In transfer/com/sql/TransferInserter.cfc, in buildInsertBasicQuery(), add the sqlType to the list of arguments passed like query.mapParam("property:" & property.getName(), property.getType(), property.getSqlType());
  4. In transfer/com/sql/TransferUpdater.cfc, do the same thing in buildUpdateBasic()

I don't know that I'm planning to do this now but it was a PITA to figure out so I want to capture it here in case anyone wants to know how it would work.

@ghidinelli
Copy link
Author

Just recently did this to support native jsonb datatype in Postgres 9.4. Complete list of files to update to make this work:

  1. transfer/com/dynamic/MementoBuilder.cfc in buildCompositePath()
  2. transfer/com/dynamic/definition/InitWriter.cfc in writeInit()
  3. transfer/com/io/XMLFileReader.cfc - disable XML validation during testing
  4. transfer/com/sql/Nullable.cfc - init(), getNullValue(), getNull(), checkNull(), get/setDefaultNull()
  5. transfer/com/sql/NullableDAO.cfc - getNullable()
  6. transfer/com/sql/Query.cfc - docs
  7. transfer/com/sql/QueryExecution.cfc - in executeQuery()
  8. transfer/com/sql/TransferGateway.cfc - listByProperty()
  9. transfer/com/sql/postgresql/TransferSelecter.cfc - writeNull()
  10. transfer/com/sql/SelectStatement.cfc - executeEvaluation()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant