An Architect's View

CFML, Clojure, Software Design, Frameworks and more...

An Architect's View

clojure.java.jdbc 0.3.2 released

December 30, 2013 ·

This release contains minor bug fixes compared to 0.3.0, with the main focus being an overhaul of docstrings etc to improve the auto-gen'd documentation.

The community documentation for java.jdbc on clojure-doc has also had a major overhaul.

Details of this release:

  • Add nil protocol implementation to ISQLParameter.
  • Improve docstrings and add :arglists for better auto-generated documentation.
  • Make insert-sql private - technically a breaking change but it should never have been public: sorry folks!
  • Provide better protocol for setting parameters in prepared statements JDBC-86.
  • Fix parens in two deprecated tests JDBC-85.
  • Made create-table-ddl less aggressive about applying as-sql-name so only first name in a column spec is affected.

Please note that the 0.3.1 release is broken and should not be used.

Tags: clojure

TestBox - replacing MXUnit and providing BDD

December 23, 2013 ·

If you've seen my tweets over the last couple of days, you'll know that I've been taking a look at TestBox, the new testing framework from the ColdBox team.

You might be thinking "Do we really need a new testing framework?" and it's a reasonable question. CFML has had a number of testing frameworks over the years but mostly we've seen each one come and go as maintainers have moved onto other things: cfUnit, then cfcUnit, then a brief resurrection of cfUnit, then MXUnit. Does anyone remember cfSpec? I liked that a lot - I like the Behavior-Driven Development style of writing tests. That's why, at World Singles, we use the Expectations library for almost all of our Clojure-based tests.

So why the interest in TestBox? My initial interest was spurred by the inclusion of the BDD style of tests which I find both more natural to read and a better fit for expressing requirements for software that is yet to be written. Then I read that TestBox has MXUnit compatibility which intrigued me - we have been using MXUnit for several years at World Singles and I don't relish having to rewrite all those tests. If TestBox could allow us to run our existing "xUnit" tests as-is while we write new tests in the BDD style, I'd be very happy.

Adam Cameron has been blogging about Test-Driven Development recently and has also picked up on TestBox. He just blogged about trying TestBox on his extensive MXUnit test suite and you can see he ran into a number of issues, all of which he has reported, and which I expect we'll see fixes for. My experience was more fruitful than his - as I mentioned in my comment on his blog post: just two small changes got the whole of our suite running flawlessly!

My next challenge was integrating TestBox into our automated build / test script, which uses Ant. TestBox provides a runner-template that shows how to do basic Ant integration. I followed that recipe but discovered there was no way for Ant to see that any tests failed and so I couldn't "fail the build" if TestBox found errors or failures. After studying the source code briefly, I realized I could extend the TestBox CFC and provide a way for the runner CFM template to access the details of the TestResult object, and write a property file that Ant could read and fail if a certain property was set. Time to fork the ColdBox Platform Github repo and send a Pull Request to add build failing functionality which Luis merged in within a few hours! Nice!

With that in place, I was able to delete MXUnit from the World Singles repo and rely entirely on TestBox for all our testing needs!

Whether you prefer the "xUnit" style of tests, with assertions, or the "BDD" style with expectations, TestBox can support you, and even if you have a lot invested in MXUnit, migration to TestBox should be straightforward (especially once they address the issues Adam has raised). I think we can be sure of ongoing support and maintenance - based on the well-established track record of the ColdBox Team. I think TestBox is a safe bet. Now you just need to start actually doing some automated testing :)

Tags: bdd · coldbox · coldfusion · tdd · worldsingles

FW/1 2.2 Released!

December 18, 2013 ·

Framework One version 2.2 is now available for production use! You can download it from the Framework One page on RIAForge. This includes one bug fix over RC2 (interaction between renderData() and trace output).

The main focus of the 2.2 release is improved support for REST APIs, through the addition of renderData() to simplify returning JSON, XML and plain text results to the caller, as well as more sophisticated route handling via "resource packs" which let you define a family of related routes for a given resource type, using a shorthand notation. For more information, see this blog post about the latest FW/1 release and the roadmap.

As noted previously, the master branch is the current stable release (2.2), and the develop branch has become the next release (2.5). 2.5 will be released next month and will be a stepping stone toward some substantial changes coming in 3.0. For more detail, read this blog post explaining the changes coming in 2.5 and 3.0.

Tags: coldfusion · fw1

clojure.java.jdbc 0.3.0 Released!

December 17, 2013 ·

The "gold" release of the Clojure contrib library that wraps JDBC is now available on Maven Central. This release has been in the works for most of this year, as it introduces large changes from the previous "gold" release (0.2.3) that aim to make the library more idiomatic and easier to use in a multi-threaded functional environment. In order to provide a smooth migration path, the old API from the 0.2.3 release has been moved wholesale to the clojure.java.jdbc.deprecated namespace, and the new API in 0.3.0 uses new naming for almost all of the (new) functionality.

The main API change is the removal of the dynamic global variable *db* and the with-connection macro. Instead you now pass the database spec as an explicit argument in all calls, and you can share connections across multiple SQL operations either by using connection pooling (recommended) or the new with-db-connection macro that takes an explicit binding for (a connected version of) the database spec.

A common problem with the old API when performing queries was that with-query-results required care because the result set was lazily constructed and it was easy to let that lazy sequence escape and have the connection closed before you had finished working on the results. The new API provides a query function that, by default, fully realizes the result set to avoid that problem. You can still process very large result sets lazily by passing :row-fn and/or :result-set-fn arguments to query.

For more details of the new API, you can read the reference documentation for clojure.java.jdbc. For a summary of all the changes made since the 0.2.3 release, read the clojure.java.jdbc change log on Github. To use the library in your project, see the clojure.java.jdbc dependency information on Github.

Detailed documentation on using clojure.java.jdbc is being developed for the Clojure Documentation Site and will be found in the java.jdbc section of the Clojure ecosystems area, once the site has been refreshed from the markdown sources on Github.

Tags: clojure

clojure.java.jdbc 0.3.0 RC1

December 13, 2013 ·

Clojure's low-level JDBC wrapper inches closer to a gold 0.3.0 release with the first release candidate. Read more on clojure.java.jdbc's Github repo. The changes in this release are:

  • Deprecate db-transaction (new in 0.3.0) in favor of with-db-transaction JDBC-81.
  • Add with-db-metadata macro and metadata-result function to make it easier to work with SQL metadata JDBC-80.
  • Add with-db-connection macro to make it easier to run groups of operations against a single open connection JDBC-79.
  • Add ISQLValue protocol to make it easier to support custom SQL types for parameters in SQL statements JDBC-77.
  • Add support for :isolation in with-db-transaction JDBC-75.
  • Add :user as an alias for :username for DataSource connections JDBC-74.

The reference documentation for clojure.java.jdbc has already been updated. The Clojure Documentation Site java.jdbc section has been updated in Github, pending a regeneration of the site.

Tags: clojure

FW/1 2.2 Release Candidate 2

December 02, 2013 ·

Framework One version 2.2 release candidate 2 is now available for testing (download from the Framework One page on RIAForge). This includes a couple of bug fixes, compared to release candidate 1. See the FW/1 2.2 RC2 release notes on Github for more details. Unless any showstopping bugs are found this week, the final 2.2 release will be made early next week, merged to master, and then develop will become the 2.5 branch.

See FW/1 Releases and Roadmap and FW/1 - The Year Ahead for more information about the upcoming 2.2, 2.5 and 3.0 releases, as well as plans for DI/1.

Tags: coldfusion · di1 · fw1

A Year With Windows 8

November 30, 2013 ·

A year ago I bought a Windows 8 laptop. How has it stood the test of time?

[Read more →]

Tags: wifi · windows8

clojure.java.jdbc 0.3.0 beta2

November 24, 2013 ·

Based on feedback from the community, I have released clojure.java.jdbc 0.3.0-beta2 to Maven Central.

This includes two very important changes:

  • The clojure.java.jdbc.sql and clojure.java.jdbc.ddl namespaces have been removed.
  • The API functions that were already marked as deprecated have moved to the clojure.java.jdbc.deprecated namespace

This means that if you depend on the clojure.java.jdbc.sql or clojure.java.jdbc.ddl namespaces, which were introduced in 0.3.0-alpha1, you will need to switch to the java-jdbc/dsl project (release 0.1.0 is on Clojars). The new namespaces in that project are java-jdbc.sql and java-jdbc.ddl. If you depend on these namespaces, I strongly recommend you migrate to a more sophisticated DSL, such as:

  • HoneySQL - https://github.com/jkk/honeysql
  • SQLingvo - https://github.com/r0man/sqlingvo
  • Korma - http://www.sqlkorma.com

More importantly, if you depend on the older (0.2.3) API in clojure.java.jdbc, you'll need to switch to the clojure.java.jdbc.deprecated namespace in your code, until you can migrate to new API in clojure.java.jdbc instead.

These steps are more radical than I would have liked but they simplify the library and streamline the API - and the auto-generated documentation - which should reduce all the confusion expressed about the library right now. This will allow the library to move forward in a more focused manner, with an API that no longer depends on dynamic variables.

Tags: clojure

Clojure/conj 2013 - a quick recap

November 18, 2013 ·

This was my third Clojure/conj and the first year it's been outside of Raleigh, NC - with the actual event at the George Washington Masonic Memorial, in a beautiful theater, and lodging at the (expensive) Embassy Suites, just a few minutes away. As usual, the caliber of the talks was (mostly) excellent - which is important in a single track conference - and the hallway / bar conversations were also very educational / entertaining!

[Read more →]

Tags: clojure

clojure.java.jdbc 0.3.0 beta 1

November 04, 2013 ·

The clojure.java.jdbc library has finally hit "feature complete" for the upcoming 0.3.0 release and so the first beta release has been made available. For full details, see the clojure.java.jdbc README on Github but here's a quick list of changes in this release:

  • query as-arrays? true now allows you to leverage lazy result fetching - JDBC-72
  • "h2" is now recognized as a protocol shorthand for org.h2.Driver
  • Tests no longer use :1 literal - JDBC-71 - (this was due to a change made in Clojure 1.6 that has since been reverted, but may be revisited in future)
  • Conditional use of javax.naming.InitialContext so the library can be compiled on Android - JDBC-69
  • New db-query-with-resultset function replaces private db-with-query-results* and processes a raw ResultSet object - JDBC-63
  • Allow :set-parameters in db-spec to override set-parameters internal function to allow per-DB special handling of SQL parameters values (such as null for Teradata) - JDBC-40

JDBC-65 (a bug affecting SQLite) will be fixed before the 0.3.0 final release. JDBC-70 (an enhancement to DDL) may also be included.

Tags: clojure