Re: DB Unit test for a table with a reserved name (`Group`)
Thank you Roberto, this solution worked for me perfectly. Much appreciated!
From: Roberto Lo Giacco <rlogiacco@us...> - 2011-02-10 17:41
I had your same problem with two tables in the SmartWeb AUTH module on a PostgreSQL database: user and group. As you can see from here I was able to use the group and user table names directly in flat xml datasets https://smartweb.svn.sourceforge.net/svnroot/smartweb/trunk/modules/auth/res/dataset.xml I think I've used the following dbUnit property/feature to dbunit to actually escape schemas AND table names... connection.getConfig().setProperty(DatabaseConfig.PROPERTY_ESCAPE_PATTERN, dialect.openQuote() + "?" + dialect.closeQuote());
On Thu, Feb 10, 2011 at 15:56, Darryl L. Pierce <[hidden email]> wrote:
> On Thu, Feb 10, 2011 at 09:26:07AM +0100, Tan Tan wrote:
> > Hi,
> > My problem is as such.
> > I'm trying to set up dbunit tests for a project on a legacy database. It
> > works out great except for one table which is unfortunately called group.
> > rather `Group`. Setting up/Creating the Group for the test works just
> > via a direct SQL Create. [various selects in my DAO that use this table
> > run through provided they are ok with the table being empty]
> > When I try to insert a dataset I either get
> > 'You have an error in your SQL syntax; check the manual that corresponds
> > your MySQL server version for the right syntax to use near 'group' at
> > 1' (when using something along the lines of <group id="myid"
> > />)
> > Or
> > 'java.lang.RuntimeException: org.dbunit.dataset.NoSuchTableException:
> > `Group`' (when using something along the lines of:
> > <table name="`Group`">
> Does it work without the backticks inside of the name? IOW:
> <table name="Group">
> I've never had to enclose the table name like that before.
> > <column>id</column>
> > <column>name</column>
> > <row>
> > <value>myid</value>
> > <value>myname</value>
> > </row>
> > </table> )
> > The table works fine in production since it's always only addressed
> > as `Group`. Is there any way at all to trick DBUnit into working with
> > table short of renaming the table (again: legacy with lots of handwritten
> > SQL)?
> > Thank you for your help.
> > Sophie
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev _______________________________________________
dbunit-user mailing list
[hidden email] https://lists.sourceforge.net/lists/listinfo/dbunit-user