I do believe that if it should work if the table was created without
quotes. It's the other way around that seems to be the issue: Quoted
creation making it case-sensitive, and the insert somehow lower-casing
column names in the request.

I looked at the JDBC driver connection parameters (
https://jdbc.postgresql.org/documentation/head/connect.html#connection-parameters),
but it doesn't really lowercase requests. There's a enabled-by-default
"column sanitizer", which lower cases column names in the response (which
is pretty weird to me, if case sensitive columns are possible, but okay),
but nothing the other way.

BR,
Dennis

On Mon, Nov 5, 2018 at 5:43 AM Vijay Kumar Jalagari
<jalag...@adobe.com.invalid> wrote:

> No, table is not created using Metamodel, It was pre-existing table.
>
> Regards,
> Vijay Kumar J
>
> -----Original Message-----
> From: Kasper Sørensen <i.am.kasper.soren...@gmail.com>
> Sent: Saturday, November 3, 2018 4:47 AM
> To: dev@metamodel.apache.org
> Subject: Re: [postgres] Insert and Update execution fails if table column
> name contains Upper case
>
> I don't have much insight. One thought though: Are you doing these
> inserts/updates with the same DataContext that you used for creating the
> table? Or was the table pre-existing? I'm asking because I guess it could
> be related to the CREATE TABLE which defined the column names too. And if
> MetaModel is responsible for creating the columns, but maybe not quoting
> their names at that time, then I could see a discrepancy occuring when you
> try to insert. So is that a possibility?
>
> Den fre. 2. nov. 2018 kl. 03.05 skrev Dennis Krøger <losdl...@gmail.com>:
>
> > According to
> >
> > https://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fwww.p
> > ostgresql.org%2Fdocs%2Fcurrent%2Fstatic%2Fsql-syntax-lexical.html%23SQ
> > L-SYNTAX-IDENTIFIERS&amp;data=02%7C01%7Cjalagari%40adobe.com%7C8b03788
> > c5d2d41d2334b08d641198126%7Cfa7b1b5a7b34438794aed2c178decee1%7C0%7C0%7
> > C636767975130637553&amp;sdata=auMPtpWSdGgxRn73RuaUqMBXRw5PbH3CCRXvynKm
> > XaM%3D&amp;reserved=0
> > ,
> > columns are case-insensitive if created without quotes, but
> > case-sensitive if created with quotes.
> >
> > I'm not entirely sure how we're handling that. It's not really a
> > difference the table creation classes handles AFAIK, and I suspect we
> > don't really expect case-sensitivity in PostgreSQL tables, but it's
> > been quite a while for me, so I might remember wrong.
> >
> > Kasper, do you have some more insight?
> >
> > BR,
> > Dennis
> >
> > On Fri, Nov 2, 2018 at 10:19 AM Vijay Kumar Jalagari
> > <jalag...@adobe.com.invalid> wrote:
> >
> > > Hi,
> > >
> > > I am using Apache metamodel with data source PostgreSQL 11 and while
> > > executing insert(InsertInto) or update statement query is failing if
> > table
> > > column name contains upper characters.
> > > According to logs statement is generating properly but it seems
> > postgresql
> > > is converting column names to lowercases.
> > >
> > > Is it know issue? Is there any workaround for resolving it?
> > >
> > > Logs
> > > org.apache.metamodel.jdbc.JdbcUtils Could not execute insert statement:
> > > INSERT INTO "public"."employee"
> > > (id,name,age,dob,mobileNo,zip,profilePicture,vendor) VALUES
> > > (?,?,?,?,?,?,?,?): ERROR: column "mobileno" of relation "employee"
> > > does
> > not
> > > exist
> > >   Position: 50, Error code=0, SQL state=42703
> > > org.postgresql.util.PSQLException: ERROR: column "mobileno" of
> > > relation "employee" does not exist
> > >   Position: 50
> > >                 at
> > >
> > org.postgresql.core.v3.QueryExecutorImpl.receiveErrorResponse(QueryExe
> > cutorImpl.java:2440)
> > > [org.postgresql.jdbc42:42.2.5]
> > >                 at
> > >
> > org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorI
> > mpl.java:2183)
> > > [org.postgresql.jdbc42:42.2.5]
> > >                 at
> > >
> > org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.jav
> > a:308)
> > > [org.postgresql.jdbc42:42.2.5]
> > >                 at
> > > org.postgresql.jdbc.PgStatement.executeInternal(PgStatement.java:441
> > > )
> > > [org.postgresql.jdbc42:42.2.5]
> > >                 at
> > > org.postgresql.jdbc.PgStatement.execute(PgStatement.java:365)
> > > [org.postgresql.jdbc42:42.2.5]
> > >                 at
> > >
> > org.postgresql.jdbc.PgPreparedStatement.executeWithFlags(PgPreparedSta
> > tement.java:143)
> > > [org.postgresql.jdbc42:42.2.5]
> > >                 at
> > >
> > org.postgresql.jdbc.PgPreparedStatement.executeUpdate(PgPreparedStatem
> > ent.java:120)
> > > [org.postgresql.jdbc42:42.2.5]
> > >                 at
> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > Method)
> > >                 at
> > > sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >                 at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >                 at java.lang.reflect.Method.invoke(Unknown Source)
> > >                 at
> > >
> > org.apache.tomcat.jdbc.pool.interceptor.AbstractQueryReport$StatementP
> > roxy.invoke(AbstractQueryReport.java:235)
> > > [org.apache.sling.datasource:1.0.2]
> > >                 at com.sun.proxy.$Proxy195.executeUpdate(Unknown
> Source)
> > >                 at
> > > sun.reflect.NativeMethodAccessorImpl.invoke0(Native
> > > Method)
> > >                 at
> > > sun.reflect.NativeMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >                 at
> > sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown
> > > Source)
> > >                 at java.lang.reflect.Method.invoke(Unknown Source)
> > >                 at
> > >
> > org.apache.tomcat.jdbc.pool.interceptor.StatementDecoratorInterceptor$
> > StatementProxy.invoke(StatementDecoratorInterceptor.java:261)
> > > [org.apache.sling.datasource:1.0.2]
> > >                 at com.sun.proxy.$Proxy195.executeUpdate(Unknown
> Source)
> > >                 at
> > >
> > org.apache.metamodel.jdbc.JdbcSimpleUpdateCallback.executePreparedStat
> > ement(JdbcSimpleUpdateCallback.java:45)
> > > [aem-dermis-core:3.0.33.SNAPSHOT]
> > >                 at
> > >
> > org.apache.metamodel.jdbc.JdbcUpdateCallback.executePreparedStatement(
> > JdbcUpdateCallback.java:71)
> > > [aem-dermis-core:3.0.33.SNAPSHOT]
> > >                 at
> > >
> > org.apache.metamodel.jdbc.JdbcUpdateCallback.executeInsert(JdbcUpdateC
> > allback.java:272)
> > > [aem-dermis-core:3.0.33.SNAPSHOT]
> > >                 at
> > >
> > org.apache.metamodel.jdbc.JdbcInsertBuilder.execute(JdbcInsertBuilder.
> > java:85)
> > > [aem-dermis-core:3.0.33.SNAPSHOT]
> > >
> > >
> > > Regards,
> > > Vijay Kumar J
> > >
> > --
> > Med venlig hilsen,
> > Dennis Du Krøger
> >
>
-- 
Med venlig hilsen,
Dennis Du Krøger

Reply via email to