Warning: Can't synchronize with repository "(default)" (/home/git/ome.git does not appear to be a Git repository.). Look in the Trac log for more information.
Notice: In order to edit this ticket you need to be either: a Product Owner, The owner or the reporter of the ticket, or, in case of a Task not yet assigned, a team_member"

Task #11663 (closed)

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

Use SQL DOMAINs in model

Reported by: mtbcarroll Owned by: mtbcarroll
Priority: minor Milestone: 5.1.0
Component: ORM Version: n.a.
Keywords: n.a. Cc: omero-team@…
Resources: n.a. Referenced By: n.a.
References: n.a. Remaining Time: 0.0d
Sprint: n.a.

Description

In defining the DB schema we should do things like,

CREATE DOMAIN positive_float AS FLOAT8 CHECK (VALUE >= 0);
CREATE DOMAIN strictly_positive_float AS FLOAT8 CHECK (VALUE > 0);

(or name them whatever they are in the model, maybe it's "non-negative" or something)

and then change the table columns to use these datatypes. This should make the table definitions clearer and constraint updates easier.

Change History (10)

comment:1 Changed 10 years ago by mtbcarroll

grep -n m....clusive ome.xsd reveals the location of some good stuff but, while ome.dsl.Property.DBTYPES and ome.dsl.SemanticType.getCheck() look strikingly relevant, I don't see what, if anything, is using or calling them, or how else the SQL schema is getting generated.

comment:2 Changed 10 years ago by jamoore

dsl is used to generate the model/target/generated/src Java files which are used by Hibernate to generate the schema.

comment:3 Changed 10 years ago by mtbcarroll

I am thinking that perhaps the client code is the $type.check code in the strange file object.vm. (Maybe getDbType() isn't used in generation.)

comment:4 Changed 10 years ago by jamoore

Glancing quickly, I think you're right; dbtype doesn't seem to be used any longer.

comment:5 Changed 10 years ago by mtbcarroll

  • Status changed from new to accepted

Thank you. It looks like changes to Property.getDef() (with reference to type) and to SemanticType.getCheck() are what's indicated.

comment:6 Changed 10 years ago by mtbcarroll

Strangely, Property.getDef() turns 4-byte XML / Java floats not into 4-byte SQL REALs but 8-byte SQL DOUBLE PRECISION instead. Is this a feature or a bug? If the latter, I wonder how big a breaking change it is to fix.

Last edited 10 years ago by mtbcarroll (previous) (diff)

comment:7 Changed 10 years ago by jamoore

See #803: basically, the SQL float was slightly too small for the Java float, so we have Java double everywhere.

comment:8 Changed 10 years ago by mtbcarroll

Aha, thank you: for the same reason, it looks like the PostgreSQL JDBC driver made a similar change in 8.1 so that Java floats going through it also become double precision. The REAL range is indeed a bit inadequate.

comment:9 Changed 10 years ago by mtbcarroll

  • Resolution set to fixed
  • Status changed from accepted to closed

comment:10 Changed 10 years ago by Josh Moore <josh@…>

  • Remaining Time set to 0

(In [09cd2fb81dd1cd70653358a6d16c32b25ac25596/ome.git] on branch develop) Merge pull request #2191 from mtbc/model-changes

fix #11663, #11664, #11877: SQL DOMAIN; import logs (rebased); FS delete log trigger

Note: See TracTickets for help on using tickets. You may also have a look at Agilo extensions to the ticket.

1.3.13-PRO © 2008-2011 Agilo Software all rights reserved (this page was served in: 0.68009 sec.)

We're Hiring!