Commit Graph

792 Commits

Author SHA1 Message Date
Ray J. Greenwell 38dee9bf09 Doc correction. 2015-07-07 16:26:27 -07:00
Ray J. Greenwell 436fc3f005 I have always wanted this constructor. I'm adding it.
RFC: I'm continuing to enforce that you must pass at least
one SQLExpression, but if we didn't care this could be a bit
more straightforward in the form:

    public Where (SQLExpression<?>... andConditions)

It could then use that array directly for the Ops.and(), but also
people would be able to make a "where true" by just constructing
a Where with no args and I'm not sure mdb is down with that.
2015-05-15 15:14:02 -07:00
Mark Johnson 3adbc2b807 Implement adding unique constraint to column in PostgreSQL.
Removing the unique constraint still unimplemented.
2015-05-07 17:20:41 -07:00
Ray J. Greenwell 009ad985a0 Fix postgres for migrating a generated id int column to long. 2015-05-07 13:19:11 -07:00
Michael Bayne 4e6d824d10 Limit our catchall exceptioning. 2015-04-02 08:01:31 -07:00
Michael Bayne 69c0763e85 Oh null, how I don't love you so. 2015-04-02 07:57:30 -07:00
Ray J. Greenwell 6b311b7a34 Properly ignore the last argument if there are an odd number.
When we saw the problem, I thought "there's no way!" because
the Logger is hardened and battle-tested.

But no. Since depot no longer depends on samskivert, it has
reimplemented Logger and throws away a lot of the goodness that
has evolved over the years. Goodness like:
- warning if there are an odd number of args and the last one
  isn't a Throwable.
- catching problems toString()ing any of the objects in the message.

Let's go ride a fixie.
2015-03-31 13:28:06 -07:00
Michael Bayne 4db33fa088 No longer support Postgres pre-8.3 FTS.
We certainly don't want that to be the default. Boy that was fun to track down.
2015-03-25 12:20:50 -07:00
Michael Bayne 2eacad24e9 Javadoc fixes, use samskivert 1.9 for testing. 2015-03-12 08:54:42 -07:00
Ray J. Greenwell eb6724ed8b Missed a spot.
Things worked without this because the DepotMarshaller ends up
checking for the existence of the table using its own code...
(TODO?)

Also JDBCUtil checks the DatabaseMetaData too but the liaison
isn't passed to that, would require some refactoring...

Actually it seems there are mountains of dead code in JDBCUtil and
they could all be removed...
2015-02-23 14:30:53 -08:00
Ray J. Greenwell e9dd7b1277 Fix problems with depot being unable to create a table called domains on postgres. 2015-02-19 15:01:44 -08:00
Michael Bayne 837daa2116 Eliminate another dubious use of Tuple2.
If only Java didn't make it so damned hard to create a simple named class with
two or more values in it. Naming is generally a good thing, especially when the
alternative is Tuple2<SQLExpression<?>,SQLExpression<?>>.
2015-02-10 13:01:09 -08:00
Michael Bayne 40e6ccc833 Tuple2<blah blah> -> IndexDesc.
If you have persistent classes with complex (or ordered) indices, you need to
return IndexDesc now instead of Tuple2<blah blah>.
2015-02-10 13:01:09 -08:00
Michael Bayne 66952dc472 Eliminated samskivert dependency.
It was a constant source of annoyance that part of the Depot implementation
lived in samskivert.jdbc. Now it all lives in Depot and samskivert can go back
to being a long obsolete library of utility methods.

Depot clients will have to make three renaming changes:

1. ConnectionProvider &c are now in com.samskivert.depot.

2. ByteEnum is now in com.samskivert.util.

3. Methods that returned index information used to return samskivert Tuple if
you wanted an expression and an order. Now they must return Depot Tuple2. This
should fail at app startup if you miss a spot, so this should not result in any
ticking timebombs.

NB: the next commit is probably going to change Tuple2 into a proper named
class because using a Tuple2 for this situation turns out to suck.

NB2: I moved DropTableMigration out of impl and put the impl details into
DepotMetaData. I should have done that separately, but it was already in
progress when I undertook to revamp.
2015-02-10 13:00:22 -08:00
Ray J. Greenwell 5c978c3777 Added a handy DropTableMigration.
Documented some caveats.
2015-02-09 18:24:12 -08:00
Ray J. Greenwell 037675ce9e A handy DropTableMigration. 2015-02-09 18:20:56 -08:00
Ray J. Greenwell ab98f85023 Array type is irrelevant.
...as far as I can tell.
Rip out the code that tried to set up the right array type.
2015-02-02 13:42:06 -08:00
Ray J. Greenwell 8981467b29 Fix copy/paste error... that was itself copy/pasted.
Strings were always being shoved into a Comparable array.
Does the array type matter? Apparently not. We should just
rip out these tests and always store in a Comparable[].
2015-02-02 13:33:27 -08:00
Ray J. Greenwell db71c3de69 Include everything. 2014-12-16 19:42:55 -08:00
Ray J. Greenwell c9930244dd Revamp OrderBy.random() for postgres compatibility. 2014-12-16 19:41:14 -08:00
Michael Bayne 190c38f8a8 Remove MAX_KEYS limit, added test.
We've had JDBC array support in Postgres for 5 years now, so I think we're
probably safe to assume it's working everywhere. Ha ha, I'm such an optimist.
2014-10-02 14:30:11 -07:00
Michael Bayne 62c17819f4 Omit Transaction.start() in favor of ctx.startTx(). 2014-10-01 14:51:37 -07:00
Michael Bayne 07934f0187 A bare-bones transaction test.
Seems to be working...
2014-10-01 14:48:47 -07:00
Michael Bayne 9cead5e7e5 Oops, let's put those statements int the right order. 2014-10-01 14:33:08 -07:00
Michael Bayne 872b2d9ef3 Some robustness bits.
It's not clear what the right thing to do is if the database connection fails
during the middle of a transaction. In general, one can't talk to the database
after that, so I'm assuming the transaction is aborted (or eventually aborted)
and rolled back, and everything has to be retried.

I'm not currently tracking state inside a Transaction, which means that I don't
freak out if you call commit() then call rollback(), I just ignore the latter
call, and it's also possible to do something stupid like:

  Transaction tx = Transaction.start(ctx);
  try {
    _somRepo.doOp(..);
  } catch (DatabaseException de) {
    // no problem!, keep on keepin' on
  }
  _someRepo.doAnotherOp(...);
  tx.commit();

If the first repo op fails due to a database connection failure, the
transaction will get a new database connection for the second op and do the
last half of the op in a new connection.

I guess I'll have to do some state tracking, because stupid as the above code
is, I'm sure some circumstance will arise where it seems like a reasonable
thing to do, and hilarity will ensue. Blah.
2014-10-01 14:27:55 -07:00
Michael Bayne d676847c24 Initial pass at transaction support.
Now to test it!
2014-10-01 14:16:48 -07:00
Michael Bayne 63f69eb843 Tweaky tweak. 2014-10-01 11:25:16 -07:00
Michael Bayne 9874be4034 Added special update() provided by Ray.
This allows one to update a record iff some additional criteria are met.
2014-10-01 11:19:21 -07:00
Michael Bayne 1d826d903f Beans/frank.
I should probably add a test for this. Ha!
2014-06-26 11:50:45 -07:00
Michael Bayne 44091660ea Migrated to Github. 2014-06-25 15:39:13 -07:00
Michael Bayne c60d8e2dde A bunch of Javadoc fixes. 2014-06-25 21:49:09 +00:00
Michael Bayne 97b404c236 Provide a modicum of thread safety for marshaller init.
The _marshallers table must be guarded as computed marshallers can be created
at any time, and marshaller initialization itself must be guarded for the same
reason.

Thanks to Ray for pointing this out.
2014-06-25 21:48:50 +00:00
Michael Bayne 3906c69a88 Liaison now handles exceptioning for us. 2014-05-02 20:46:36 +00:00
Michael Bayne f2be63ec19 Choke usefully if we can't obtain last inserted id. 2014-05-02 20:14:43 +00:00
Ray Greenwell 800add9667 Clean up imports. 2014-05-02 18:28:50 +00:00
Michael Bayne 9ebd2c677c Use new smarter DatabaseLiaison.lastInsertedId. 2014-05-02 18:19:51 +00:00
Ray Greenwell 2cf224dd18 Whoops! My last edit didn't actually work, it ended up falling back.
This works, but mdb is going to move the special caseyness inside the Liaison.
2014-05-02 18:12:46 +00:00
Ray Greenwell 1a9fc404ba Ok, this works on both mysql and postgres.
On mysql the column name ends up being "GENERATED_KEY".
2014-05-02 01:31:58 +00:00
Ray Greenwell e2a9702c46 This getGeneratedKeys business doesn't seem to work for us on mysql.
Trying a catch/fallback. This should at least provide a workaround for now...
2014-05-01 23:01:55 +00:00
Michael Bayne e08911369e Only use RETURN_GENERATED_KEYS on inserts.
This works around "unsophisticated" Postgres JDBC drivers which blindly tack
"RETURNING *" onto a query if RETURN_GENERATED_KEYS is supplied.
2013-11-20 19:45:24 +00:00
Michael Bayne ca4ec1f4d3 Reverse order in addAll(List,Cons).
This causes the elements of the list to match the original order they were
added to the cons list (which stores elements "backwards").

This order matters for joins, as Ray discovered.
2013-10-10 22:06:34 +00:00
Michael Bayne 99a4d7a18e Only rewrite record file if it changed. 2013-09-17 19:07:19 +00:00
Michael Bayne bc8a18dec5 Factor the logic of genrecord from the Ant harness. 2013-09-17 19:07:16 +00:00
Michael Bayne 58ede042a6 Fixed some use of wrong log helper. 2013-05-24 18:45:26 +00:00
Michael Bayne 8a74276caf Various tidyings. 2013-05-24 18:30:57 +00:00
Michael Bayne 952d01c55b Info -> debug for initial version record message.
It's not that important. We already log a message indicating that we created
the table for the first time, which will always follow this message.
2013-05-24 18:30:53 +00:00
Michael Bayne 1bee1d0351 Revamp identity value generator to use Statement getGeneratedKeys.
Most JDBC drivers have supported this for ages. No longer do we need the
hackery of turning around and doing another query to obtain generated key
values.
2013-05-16 18:42:16 +00:00
Michael Bayne 81c24f56bf Fix rawtypes. 2013-05-16 18:42:13 +00:00
Michael Bayne 0b5369fd11 Do this cast in a way that Java 7 doesn't complain about. 2013-05-16 18:42:09 +00:00
Michael Bayne 0c26a26ce0 Bump HSQLDB to 2.9, fix test that assumed count(*) returned int. 2013-05-16 18:42:05 +00:00