Commit Graph

622 Commits

Author SHA1 Message Date
Michael Bayne aa879c3019 Allow the release version to be specified on the command line. 2010-08-27 17:57:38 +00:00
Michael Bayne 6f7527ec6b Fixes to Ivy-based build. 2010-08-27 17:54:06 +00:00
Michael Bayne 3535ffc9fd Got moved to src/tests/java. 2010-08-27 17:49:46 +00:00
Michael Bayne 28f9439b5f More layout standardizing. 2010-08-27 17:49:18 +00:00
Michael Bayne 6778ada227 Moving toward more standard project layout. 2010-08-27 17:47:07 +00:00
Michael Bayne 5a97565eaa New HSQLDB requires length for VARBINARY. 2010-08-27 17:41:11 +00:00
Andrzej Kapolka 2471487d2f Oops, that will never be null. 2010-08-18 22:43:33 +00:00
Andrzej Kapolka af0c636517 More fixes for named columns. DepotMarshaller expects the names of the
columns in the results to match the FieldMarshaller column names, so we have
to use those rather than the field names.  Also, shadowed fields need to use
the column names of the fields that they're shadowing.
2010-08-18 22:40:03 +00:00
Andrzej Kapolka 061219bc57 Postgres returns a timestamp from date_trunc, whereas MySQL returns a
date from date().  We should probably just modify DateFuncs.date to
return a date in both cases (perhaps with a separate DateFun.DateCast
class), but for now it's easier to have MySQL return a timestamp as
well.
2010-07-22 21:37:11 +00:00
Andrzej Kapolka 27ff0f6f55 And this should be getting the column name, too (though it doesn't
actually do anything yet except log a message).
2010-07-15 00:50:59 +00:00
Andrzej Kapolka cd94a13551 While I'm in there, this also looks wrong. 2010-07-15 00:30:40 +00:00
Andrzej Kapolka 5dd3ae92a5 Looks like this should be the column name, not the field name. 2010-07-15 00:22:28 +00:00
Ray Greenwell c7ce640a78 Prefer Guava to Samskivert. 2010-07-14 18:51:40 +00:00
Michael Bayne e2a73dfa61 Use Unix line endings. 2010-07-07 15:50:46 +00:00
Ray Greenwell 9d83cc96a5 For the String[] transformer, encode null elements as "\" followed by
the terminator (we encode the terminator as a different character).
This is somewhat nicer when inspecting an encoded String, and allows
for a future in which the decoder easily counts the number of terminator
characters and pre-allocates the storage, if we so desired.
2010-07-06 20:54:48 +00:00
Ray Greenwell 95f2fc6938 A Transformer from a Set<ByteEnum> -> Integer, plus some new tests. 2010-07-06 18:30:32 +00:00
Michael Bayne 5ec15839d3 Factored shared code into a base class. Restructured to avoid double checking
for null.
2010-07-06 18:22:09 +00:00
Michael Bayne 0b84e08917 Nixed deprecated transformer. 2010-07-06 18:15:37 +00:00
Ray Greenwell 20e06e9789 Ready my Transformer for prime time.
There are some optimizations that could probably be made, but
for now I defer to the new One Rule of Optimization:
"Do not optimize for performance unless it does not weird the code or
it Really Matters".
2010-07-05 22:43:13 +00:00
Ray Greenwell 2b71609148 I should change the name of this test... 2010-07-05 22:36:18 +00:00
Ray Greenwell 48279471e1 Updated tests. 2010-07-05 22:34:15 +00:00
Ray Greenwell eef66bcaee Changed my String[] Transformer:
- continue to terminate Strings with a newline
- turn newlines inside a String into "\n"
- turn null elements into "\0".

This is one additional character when encoding nulls, but
I think it may improve readability..
2010-07-05 22:10:56 +00:00
Michael Bayne 0e82904696 Provide the Transformer with the field's Type rather than it's Class. The Type
contains generic type information which would allow a transformer to do the
right thing with a field of, say, type Set<Integer>.

If we had unit tests for StringIterable, I'd know that I didn't just break it.
I'd also know that it worked in the first place. :)
2010-07-05 21:43:10 +00:00
Ray Greenwell a5fee01354 Maybe I can generalize this into a rule: if either of operands 2 or 3
to the ternary operator are boolean constants, don't use the ternary operator.

a ? true : x   ==  a || x
a ? x : true   ==  !a || x
a ? false : x  ==  !a && x
a ? x : false  ==  a && x
2010-07-05 21:32:28 +00:00
Ray Greenwell f2f995766b A demonstration of the failing of the current String[] transformer.
I'll do some more tests and nix this one today.
2010-07-05 14:16:00 +00:00
Ray Greenwell ce1d06e82b I was trying to be clever with newline and save a character,
but I forgot about that cleverness in fromPersistent, so skip it for now.
2010-07-02 03:56:26 +00:00
Ray Greenwell f4c7b7fef4 Better String[] Transformer, RFC. 2010-07-02 03:49:43 +00:00
Par Winzell 846ea920b6 Make the adapter configurable, as was always the intention. 2010-07-01 17:15:32 +00:00
Par Winzell a0e8c602ed Maintain correct record counts for cacheless finds. 2010-06-24 18:15:40 +00:00
Michael Bayne 75a22f5584 Nix joiner. 2010-06-19 18:05:46 +00:00
Michael Bayne 728159dc48 Replace the CommaSeparatedString transformer with an escaping
TabSeparatedString transformer. Maybe I should just use StringUtil methods...
2010-06-19 18:05:23 +00:00
Michael Bayne f4cc4f2bee Move the repository south to match AllTypesTest. 2010-06-19 17:52:52 +00:00
Michael Bayne 978bf81acb Added support for boxed booleans. I have to admit that adding it to the test
case, seeing it fail, then adding the code to handle it was rather satisfying.

I'm not jumping on the TDD bandwagon or anything, but libraries like Depot are
clear cases where vigorous unit testing is a big win.
2010-06-19 17:48:51 +00:00
Michael Bayne 9d9ba71c97 Import tidying. 2010-06-19 17:45:28 +00:00
Michael Bayne d0dd828925 Comment our workarounds. 2010-06-19 17:44:55 +00:00
Michael Bayne 45ec7cf77c Implemented the ColumnTyper interface for our various builders. 2010-06-19 17:41:10 +00:00
Michael Bayne 5587d134bd Request the appropriate length for int arrays. 2010-06-19 17:40:03 +00:00
Michael Bayne ff53b67e3d Test that @Transform works in its various supported use cases, and fails as
early as possible in situations where the developer is fucking up.
2010-06-19 17:36:04 +00:00
Michael Bayne 7f9bf7b589 Determined that we need to pass the field type into the fromPersistent() to
support use cases like ByteEnum. (Even though I'm leaving ByteEnum support
hard-coded for the time being.)
2010-06-19 17:35:05 +00:00
Michael Bayne 1d9a19e502 Unit tests for all supported field types (including null versions). 2010-06-19 17:34:21 +00:00
Michael Bayne 06c36fbed2 - Added support for @Transform annotation.
- Revamped column type determination to use a mechanism that supports
  delegation and does not rely on a heap of instanceof calls (which results in
  runtime failure rather than compile time failure when a new column type is
  added)
- Discovered that HSQLDB (at least) does not handle Byte, Short and Float
  correctly. It returns them as Integer, Integer and Double respectively, which
  then causes failure when trying to write those values back to the fields. We
  work around this by converting non-null results to the correct type after we
  get them back from the JDBC driver.
2010-06-19 17:33:55 +00:00
Michael Bayne a4e7f3fb47 Make "ant -Ddebug=true tests" run the tests with SQL debugging on. 2010-06-18 23:49:32 +00:00
Michael Bayne 6fd404587f Allow a specific test to be run with "ant -Dtest=Foo tests". 2010-06-18 23:12:27 +00:00
Michael Bayne 5e77d29c47 Test good and bad byte enum marshaller creation. 2010-06-18 22:49:02 +00:00
Michael Bayne 0950fdd4ea Transformers: more than meets the eye.
This is an unimplemented proposal for handling non-basic types in Depot in an
extensible way, instead of continuing down the road of the ByteEnum-style
hackery that we've been doing to date. The basic design is as follows:

Annotate either a field or a class with @Transform and specify the classname of
a Transformer in that annotation. For example:

 public class MyRecord extends PersistentRecord {
     @Transform(Transformers.CommaSeparatedString.class)
     public String[] cities;
 }

will cause "cities" to be combined into a single string (comma separated)
before storing in the database, and split back into a string array from the
single string when read from the database.

Alternatively, one can annotate a type:

 @Transform(ByteEnumTransformer.class)
 public interface ByteEnum { ... }

If Depot sees a field of non-basic type, it will look for a @Transform
annotation on the field's type (and any interfaces implemented by that type or
its parent types, which is not auto-magic). If it finds one, it will use it.
Otherwise it will fall back to what it does now (which I think is to just foist
the object off to JDBC and hope for the best).

Comments and suggestions are invited.
2010-06-17 19:11:35 +00:00
Michael Bayne f722d1b2df There must be a way to have svn magically put in the current year. 2010-06-17 19:05:21 +00:00
Par Winzell 2125367297 Automatically handle changes to primary key by dropping the old one (which triggers the creation of the new one). 2010-05-06 14:38:52 +00:00
Par Winzell f54c74e385 Abstract records should never be directly referenced; fail as early as possible and explain what's going on. 2010-05-06 14:37:18 +00:00
Ray Greenwell 743ca150cf Patch from Jamie Doornbos: update Eclipse file to match the move to guava, in r600. 2010-04-16 16:40:29 +00:00
Michael Bayne 70a16d64ad Back to the freakoutery. Nathan's going to use the existing (if somewhat
verbose) mechanisms to accomodate his needs. We freak out as early as possible
to save the developer a time wasting debugging session in situations where they
update only one or the other of the persistent and runtime class, or make a
typo, or get the types wrong, etc.
2010-04-10 00:28:26 +00:00