Actually I think a RDBMS would typically reject the query if you try to do
a filter in SQL a la:

SELECT * FROM person WHERE name > 1

(name being a string type)

2015-03-29 6:09 GMT+02:00 Ashish Mukherjee <[email protected]>:

> Well, I am using a CsvDataContext with an id column. Hence, data type is
> not really defined in a meta-data schema (which it would be for a RDBMS).
> Hence, the expected behaviour would be to use the data type of the value
> provided. If the column meta-data mentions that it is a different type,
> then the expected behaviour would be to cast the value and do a comparison
> IMO.
>
> eg. if id was a string field in a db table and I provide an Integer filter
> (say, 1). Then, the value of the id field should be cast to int and
> compared against 1.
>
> Other way to look at it is that the field meta-data should override the
> type that is passed. This is not how RDBMS works though, so may not be the
> expected behaviour.
>
> Shall I report this as an issue?
>
> On Sat, Mar 28, 2015 at 11:57 PM, Kasper Sørensen <
> [email protected]> wrote:
>
> > Hmm not really sure. It's a good cause for discussion maybe. I am
> guessing
> > that your "id" column is of some String type and not a number type. So
> when
> > doing a filter on it MetaModel recognizes that you have passed a
> different
> > type (Integer). In this case it "solves" the issue by using the
> > ToStringComparator. Whether it's a feature, a bug or a place for
> > improvement ... I am not sure. What do you think?
> >
> > 2015-03-27 13:24 GMT+01:00 Ashish Mukherjee <[email protected]
> >:
> >
> > > Hello,
> > >
> > > I am running a query with the following code snippet -
> > >
> > > ....
> > >
> > > Table[] tables = schema.getTables();
> > >
> > > DataSet ds =
> > >
> > >
> >
> dataContext.query().from(tables[0]).select("id").where("id").greaterThan(new
> > > Integer(1)).execute();
> > >
> > > while (ds.next()) {
> > > Row row = ds.getRow();
> > > System.out.println(row.getValue(0));
> > > }
> > >
> > > However, I see this log message -
> > >
> > > 54 [main] INFO org.apache.metamodel.util.ObjectComparator - Using
> > > ToStringComparator because no better comparison method could be found
> > >
> > > Is this issue being looked at or should it be reported/fixed?
> > >
> > > Regards,
> > > Ashish
> > >
> >
>

Reply via email to