Commit Graph

764 Commits

Author SHA1 Message Date
Michael Bayne 1e2f88ac77 Factor out the canonical order generation as we'll still need this for the
static newKey() methods even if we revamp this whole business.
2010-03-04 07:01:49 +00:00
Michael Bayne 21132b4edb Be stricter about our primary key requirements here. 2010-03-04 07:01:07 +00:00
Michael Bayne a970856aae Well, we can at least write a unit test for this super special business.
However, I started making HSQL work a long time ago so that we could have real
unit tests that did real meaningful things, and Zell was kind enough to finish
making HSQL work, so we should be able to do some real end-to-end testing. I
just need to set up the necessary scaffolding. On the list!
2010-03-04 02:57:49 +00:00
Michael Bayne c017ec5bd1 Provide a fast path for key construction in the rather common case of a
non-composite key (where ordering cannot be a problem). Boy I really wish I had
unit tests...
2010-03-04 02:45:42 +00:00
Ray Greenwell 57e3cce8d0 Return this until/unless I tackle field sorting. 2010-03-03 17:04:16 +00:00
Ray Greenwell 37c348a305 I might get my head chopped off for this one, but presumably the generated
Key construction code "knows what it's doing" and can call the optimized
Key constructor. We can rollback if I'm missing something.
2010-03-03 03:59:02 +00:00
Ray Greenwell 96e858070a This static shared map should really be a ConcurrentMap. 2010-03-03 03:57:54 +00:00
Ray Greenwell 93d90083a1 Use single quotes around the truncation parameter.
(Assume future enums in DateTruncate will correspond to the postgres args).
2010-03-02 21:36:29 +00:00
Andrzej Kapolka cb86b6def4 If we're shadowing a field, let's try using the shadowed column's name. 2010-03-02 21:30:20 +00:00
Ray Greenwell 42d99f90ca Some language about the proper usage of Sequence. 2010-02-25 23:17:06 +00:00
Ray Greenwell 0b51d1e62f Formatting. 2010-02-25 22:35:15 +00:00
Par Winzell 4b1ffe3df9 We need to specify that we want to call the varargs version, not the Iterables version. Screw Java. 2010-02-25 18:48:54 +00:00
Par Winzell 6930ed5b40 Bring back this test: WithKeys's constructor begins with iterator().next().getClass() and it's not obvious to me that it can made to elegantly not knowing that class. 2010-02-25 18:48:24 +00:00
Par Winzell 0b8be77564 Unused import. 2010-02-25 18:47:17 +00:00
Michael Bayne aa4ac73e5d Fixed some javadoc bugs. 2010-02-25 06:52:07 +00:00
Michael Bayne b5e7ba8642 Whitespace patrol. 2010-02-25 06:49:07 +00:00
Michael Bayne b8d957ce4c Accept Iterable rather than Collection everywhere we reasonably can.
Note one potentially consequential diff in DepotRepository:

-        return keys.isEmpty() ? Collections.<T>emptyList() :
-            _ctx.invoke(new FindAllQuery.WithKeys<T>(_ctx, keys));
+        return _ctx.invoke(new FindAllQuery.WithKeys<T>(_ctx, keys));

This should not actually impact anything. FindAllQuery.WithKeys first checks
for keys that are cached, coping with a potentially empty set (there will be
none), then if there are keys that remain to be loaded from the database, it
loads them. The first check will NOOP as will the second check. So this should
just be a slightly more circuitous path to getting back an empty collection. It
should not result in a zero row matching query being sent to the database.

With that in mind, it seemed inelegant to prematurely optmize the return of an
empty collection.
2010-02-25 06:48:27 +00:00
Michael Bayne 950653960b Separate SeqImpl out of Sequence, hiding it away in our impl package tree. Make
Sequence an interface.

We're going to change all of the places in Depot where we take a Collection as
an argument and take an Iterable instead. We invariably just turn the
Collection to an array, and we can just as well do that with an Iterable and be
more flexible about what we accept. Iterables.toArray has a fast path for
Iterable instances that also implement Collection, so we make SeqImpl implement
Collection under the hood even though we don't advertise that in the Sequence
interface because we don't want people using these as collections.

What we really want is something in between Iterable and Collection that knows
its size but otherwise does not allow mutation or containment checks.
2010-02-25 06:30:12 +00:00
Ray Greenwell 503f3893cb XList is now an ex-List. 2010-02-25 06:12:22 +00:00
Ray Greenwell e972ebc72b Added toSet(). 2010-02-24 22:01:25 +00:00
Ray Greenwell 6255819745 Twice now I've blown this comment. 2010-02-24 17:34:03 +00:00
Ray Greenwell 17a6cb3332 Comment pedantry.
Considered adding a note that toArray() is generally not safe, but the
Collections run through here in normal depot usage will be safe to use.
Check out the implementation of AbstractCollection's toArray(T[]).
2010-02-24 02:07:36 +00:00
Ray Greenwell 9444cad7d8 Check our preconditions for fast failure, and added toArray(). 2010-02-23 22:27:30 +00:00
Michael Bayne e251cd9944 This guy needs also to be marked deprecated to let the compiler know that I
know that it's implementing a deprecated interface method.
2010-02-23 08:54:54 +00:00
Michael Bayne 54b7bf9e99 Bring on the deprecation warnings. 2010-02-23 08:47:46 +00:00
Michael Bayne b022382231 XList is going away. To be replaced with this, still somewhat out of place in a
database library but at least slightly more ignorable, bit of functional
helpfulness.
2010-02-23 08:35:30 +00:00
Michael Bayne 152ff056d9 Charlie has convinced me that the database manipulation operations should be
public and I should not force everyone who wants to use Depot to route all
database accesses through custom public methods that hide all of the underlying
Depot business behind application specific APIs.

I still think this is the best way to use Depot, but I acknowledge that there
are certain valid use cases (like generic code that operates on records in
arbitrary repositories) which are precluded by this scheme. So instead I'll
just strongly suggest that Depot be used in the way I think it should, and
frown sternly at anyone who deviates from The Way.
2010-02-23 07:30:58 +00:00
Par Winzell 1fe2c451f8 Both In() and IsNull() will work on general expressions, not just columns. 2010-02-22 18:58:57 +00:00
Michael Bayne cdeb8eac8a Fail with a useful error message any time a migration tries to reference a
non-existent field.
2010-02-10 16:47:31 +00:00
Ray Greenwell 9661056e10 Be more flexible: follow the "PECS" rule for our Function. 2010-02-05 02:33:57 +00:00
Andrzej Kapolka 4fca0623dd Ray's patch to fix empty table insertion. 2010-02-03 20:36:16 +00:00
Par Winzell 94d381b8cc It's convenient when the toString()'d values are valid SQL. 2010-01-27 17:09:41 +00:00
Par Winzell d079445420 I'm not sure why I thought this was a good idea last night, even temporarily for testing, but it's certainly not anymore. 2010-01-27 17:08:12 +00:00
Par Winzell f0c8d185f0 With last night's patch to MultiKeySet, we'll be using a lot more IN() statements, and some of them contain shorts and bytes. Handle it. 2010-01-27 15:21:57 +00:00
Par Winzell c8eb3be297 An ancient TODO entry, now with a checkbox next to it. The way we load records (by loading keys first, then the records by key) has hitherto created really cumbersome expressions when the records in question have multi-column keys. We'd get basically SELECT * from FOO where (A = 1 and B = 'x') or (A = 1 and B = 'y') or ... and so forth, for another 30,000 arguments. This happens constantly, and we're not sure we want to trust PostgreSQL to always be handling such a flagrantly suboptimal structure elegantly. So, we now optimize it ourselves. When possible, turn constructions like the previous into where (A = 1 and B in ('x', 'y', ...)). This code has not been tested against serious amounts of data, so I am doing a sneaky midnight commit to easily test on Whirled Dev. 2010-01-27 07:39:43 +00:00
Par Winzell 784d3c18ca Typo fix, TODO note. 2009-12-10 15:48:54 +00:00
Par Winzell 4c21819f22 Adapt to the new google-collect jar. Thanks Charlie. 2009-11-11 20:41:31 +00:00
Par Winzell 6d745b4247 Roll back Charlie's constructor patch. It's an admirable idea but it just adds too much unwieldy boilerplate to large records, and neither of us like the idea of on/off switches. We'll just have to construct by hand. 2009-10-29 17:38:47 +00:00
Par Winzell 116679ebfe Get rid of @Column(type=...) which was always an abomination. 2009-10-29 16:33:34 +00:00
Par Winzell 4e390ecb0e Charlie's patch to generate field-instantiating constructors for records that do not have existing (non-generated) constructors. Generated, nullable or default-value'd fields are ignored by the constructor. 2009-10-26 15:30:53 +00:00
Par Winzell 4b43b7d099 We'd accidentally conflated SQL expressions and SQL clauses into the one interface SQLExpressionsf, which would allow statements like 'FooRecord.BAR.add(FooRecord.getKey(1))' to compile erroneously. Let SQLExpressions and QueryClauses both be subclasses of a new type SQLFragment, and let our ExpressionVisitor be a FragmentVisitor. 2009-10-23 13:59:47 +00:00
Par Winzell 8f25455481 More convenient multi-column indexing! From Charlie. 2009-10-15 16:21:14 +00:00
Par Winzell 27b7790275 Remove some superfluous bits. From Charlie. 2009-10-15 16:20:55 +00:00
Par Winzell 9c0c3be37b Aii, ColumnDefinition.defaultValue is null when it's unset, unlike the annotation. 2009-09-29 20:10:07 +00:00
Par Winzell d3e10710d2 Whitespace tweak. 2009-09-25 00:47:33 +00:00
Andrzej Kapolka e2d4269516 Patch from Nathan to support longs. 2009-09-25 00:41:18 +00:00
Par Winzell 4a552b29bc Let's not run this MySQL atrocity unless absolutely necessary. 2009-09-22 21:33:42 +00:00
Michael Bayne 681f420b8f Patch from Charlie to always commit if auto-commit is off. 2009-09-22 01:54:38 +00:00
Michael Bayne 04dc2daa8b More Galileo hygiene. 2009-09-15 04:53:50 +00:00
Michael Bayne 6a4c14b1eb Some Galileo inspired raw type elimination. 2009-09-14 22:18:09 +00:00