Received: from maia.hub.org (maia-5.hub.org [200.46.204.29]) by mail.postgresql.org (Postfix) with ESMTP id 374AEB60711 for ; Fri, 3 Jun 2011 20:05:55 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.29]) (amavisd-maia, port 10024) with ESMTP id 62389-06 for ; Fri, 3 Jun 2011 23:05:48 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-pz0-f46.google.com (mail-pz0-f46.google.com [209.85.210.46]) by mail.postgresql.org (Postfix) with ESMTP id 37FB3B605BE for ; Fri, 3 Jun 2011 20:05:48 -0300 (ADT) Received: by pzk9 with SMTP id 9so994868pzk.19 for ; Fri, 03 Jun 2011 16:05:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to:x-mailer; bh=bOThlpQo7QOIv+xg2QA65np68fox1fgvOHe1gUYQu+E=; b=rGg3un6lMSgywtXNfQ5dsmCvC2ugDDRWi/t6qV2z2x2vHTEDeXeJDmnrJA0aEwKRZa xHW8GMe20yqX5DQ1/6aRTzRsrURUiojQ5iiTHX7ff74tvkikvFRXhOQvxaPpjcKZ8xyn xd+DvhMcQLKzZ/349Nrz1dxMECwc6kjwBO7V4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=subject:mime-version:content-type:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to:x-mailer; b=RPTeBoGTx2OI6Cvr81DkK2xrJNGJohUjsppc01Dx8Pnj5MgQt/FiHZK34zppINaSOW AdJxaqdb/WSaVSYVntj0GCpYo97mgh18zopmZsJe5pU+Q7VF0FB31miAzU7X/VjgmIJt ex9Vcgo9a+eM3QFo94bb9SeN9TCZvR7zGCCpo= Received: by 10.142.163.16 with SMTP id l16mr365149wfe.446.1307142347776; Fri, 03 Jun 2011 16:05:47 -0700 (PDT) Received: from sexy.pa.trumpet.io (c-76-21-5-154.hsd1.ca.comcast.net [76.21.5.154]) by mx.google.com with ESMTPS id c3sm1780104pbk.61.2011.06.03.16.05.46 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 03 Jun 2011 16:05:47 -0700 (PDT) Subject: Re: Accepting Object[] as an acceptable input to setObject with Types.ARRAY? Mime-Version: 1.0 (Apple Message framework v1084) Content-Type: text/plain; charset=us-ascii From: Steven Schlansker In-Reply-To: Date: Fri, 3 Jun 2011 16:05:45 -0700 Cc: pgsql-jdbc@postgresql.org Content-Transfer-Encoding: quoted-printable Message-Id: References: To: Oliver Jowett X-Mailer: Apple Mail (2.1084) X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.898 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, RFC_ABUSE_POST=0.001 X-Spam-Level: X-Archive-Number: 201106/12 X-Sequence-Number: 21936 On Jun 3, 2011, at 3:47 PM, Oliver Jowett wrote: > On 4 June 2011 08:04, Steven Schlansker = wrote: >=20 >> It looks like adding support for such a fix to the Postgres driver = would be extremely easy. In particular looking around = AbstractJdbc2Statement.java:1732 >>=20 >> case Types.ARRAY: >> if (in instanceof Array) >> setArray(parameterIndex, (Array)in); >> else >> throw new PSQLException(GT.tr("Cannot cast an = instance of {0} to type {1}", new = Object[]{in.getClass().getName(),"Types.ARRAY"}), = PSQLState.INVALID_PARAMETER_TYPE); >> break; >>=20 >> it could check if in is an array type and if so synthesize the Array = object necessary. >>=20 >> Does this sound like a reasonable feature request? Did I miss an = easier way to do this? It is probably outside of the JDBC spec but it = at least has some traction with H2... >=20 > How do you determine the type of the (server-side) array elements? > i.e. what is the typename that setObject would pass to createArrayOf() > when it encountered an Object[]? The patch I put in another branch of this thread does basic type = introspection. It handles all the primitive types, wrapped types, and a = few SQL types (i.e. Date, Time, Timestamp, byte[])