I typo'd on that last test run, the header should read:
==== [ActiveRecord("[Group]")] ====
not ===== [ActiveRecord("Group")] =====
Sorry.
-jt
On Oct 8, 10:56 am, James Thigpen <[EMAIL PROTECTED]> wrote:
> I wrote an overly ghetto test.
>
> ===========================================================================
>
> using System;
> using System.Collections;
> using System.Collections.Generic;
> using System.Linq;
> using System.Text;
> using Castle.ActiveRecord;
> using Castle.ActiveRecord.Framework.Config;
> using NUnit.Framework;
> using PropertyAttribute = Castle.ActiveRecord.PropertyAttribute;
>
> namespace SqliteEscapeTest
> {
> [ActiveRecord("`Group`")]
> public class Group : ActiveRecordBase<Group>
> {
> [PrimaryKey]
> public int Id { get; set; }
>
> [Property]
> public string Name { get; set; }
> }
>
> //[ActiveRecord("Group")]
> //public class Group : ActiveRecordBase<Group>
> //{
> // [PrimaryKey]
> // public int Id { get; set; }
>
> // [Property]
> // public string Name { get; set; }
> //}
>
> //[ActiveRecord("[Group]")]
> //public class Group : ActiveRecordBase<Group>
> //{
> // [PrimaryKey]
> // public int Id { get; set; }
>
> // [Property]
> // public string Name { get; set; }
> //}
>
> [TestFixture]
> public class Test
> {
> [Test]
> public void DoesItEscapeSqliteCorrectly()
> {
> var properties = new Dictionary<string, string>();
>
> properties.Add("connection.driver_class",
> "NHibernate.Driver.SQLite20Driver");
> properties.Add("dialect",
> "NHibernate.Dialect.SQLiteDialect");
> properties.Add("connection.provider",
> "NHibernate.Connection.DriverConnectionProvider");
> properties.Add("connection.connection_string", "Data
> Source=PurpleOps.sqlite;Version=3;New=True;");
>
> InPlaceConfigurationSource source = new
> InPlaceConfigurationSource();
>
> source.Add(typeof (ActiveRecordBase), properties);
>
> ActiveRecordStarter.Initialize(source, typeof (Group));
> ActiveRecordStarter.GenerateCreationScripts(@"C:
> \Test.sql");
> ActiveRecordStarter.CreateSchema();
> }
>
> }
>
> }
>
> ===========================================================================
>
> It has 3 Definitions of Group, and I run the test 3 times uncommenting
> one and commenting out the others.
>
> ===== [ActiveRecord("`Group`")] =====
>
> Test.Sql Contents:
>
> drop table if exists Group"
> create table Group" (Id integer, Name TEXT, primary key (Id))
>
> Test Run Result:
> System.Data.SQLite.SQLiteException: SQLite error
> unrecognized token: "" (Id integer, Name TEXT, primary key (Id))"
> at System.Data.SQLite.SQLite3.Prepare(String strSql, SQLiteStatement
> previous, ref String strRemain)
> at System.Data.SQLite.SQLiteCommand.BuildNextCommand()
> at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)
> at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean format, Boolean throwOnError, TextWriter
> exportOutput, IDbCommand statement, String sql)
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean justDrop, Boolean format, IDbConnection
> connection, TextWriter exportOutput)
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean justDrop, Boolean format)
> NHibernate.HibernateException: SQLite error
> unrecognized token: "" (Id integer, Name TEXT, primary key (Id))"
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean justDrop, Boolean format)
> at NHibernate.Tool.hbm2ddl.SchemaExport.Create(Boolean script, Boolean
> export)
> at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema()
> Castle.ActiveRecord.Framework.ActiveRecordException: Could not create
> the schema
> at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema()
> at SqliteEscapeTest.Test.DoesItEscapeSqliteCorrectly() in Class1.cs:
> line 62
>
> ===== [ActiveRecord("Group")] =====
>
> Test.Sql Contents:
>
> drop table if exists Group
> create table Group (
> Id integer,
> Name TEXT,
> primary key (Id)
> )
>
> Test Run Result: Fail
>
> System.Data.SQLite.SQLiteException: SQLite error
> near "Group": syntax error
> at System.Data.SQLite.SQLite3.Prepare(String strSql, SQLiteStatement
> previous, ref String strRemain)
> at System.Data.SQLite.SQLiteCommand.BuildNextCommand()
> at System.Data.SQLite.SQLiteCommand.GetStatement(Int32 index)
> at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery()
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean format, Boolean throwOnError, TextWriter
> exportOutput, IDbCommand statement, String sql)
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean justDrop, Boolean format, IDbConnection
> connection, TextWriter exportOutput)
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean justDrop, Boolean format)
> NHibernate.HibernateException: SQLite error
> near "Group": syntax error
> at NHibernate.Tool.hbm2ddl.SchemaExport.Execute(Boolean script,
> Boolean export, Boolean justDrop, Boolean format)
> at NHibernate.Tool.hbm2ddl.SchemaExport.Create(Boolean script, Boolean
> export)
> at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema()
> Castle.ActiveRecord.Framework.ActiveRecordException: Could not create
> the schema
> at Castle.ActiveRecord.ActiveRecordStarter.CreateSchema()
> at SqliteEscapeTest.Test.DoesItEscapeSqliteCorrectly() in Class1.cs:
> line 62
>
> ===== [ActiveRecord("Group")] =====
>
> Test.sql Contents:
>
> drop table if exists [Group]
> create table [Group] (
> Id integer,
> Name TEXT,
> primary key (Id)
> )
>
> Test Run Result: Success
>
> Versions:
> This version is compiled against:
> Rhino-Tools - r1623 (Using the sqlite from the build of this,
> 1.0.35.1)
> Castle - r5299
> NHibernate - r3737
>
> Is this a bug or do I misunderstand something?
>
> -jt
>
> On Oct 8, 10:09 am, "Ayende Rahien" <[EMAIL PROTECTED]> wrote:
>
> > It most certainly should have done that. My experience says that it does,
> > mind you
>
> > On Wed, Oct 8, 2008 at 6:57 PM, James Thigpen <[EMAIL PROTECTED]>wrote:
>
> > > I've also run into a problem where an sqlite database didn't properly
> > > escape a table name that I had used backticks (`) around in my
> > > ActiveRecord attribute. (I think the table name was Group).
>
> > > I was under the impression that NHibernate magicked the backticks into
> > > the appropriate database-specific quote character. Is that not
> > > correct?
>
> > > -jt
>
> > > On Oct 6, 2:39 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > > wrote:
> > > > Thx for quick answer Ayende.
> > > > But in the end I was debugging nHibernate :)
>
> > > > The problem was that I used reserved name for one of my table -
> > > > "Order".
> > > > And it seems that for SQLite, to escape such name you need to use
> > > > brackets.
> > > > So use "[Order]" not `Order`, like I did.
>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Rhino Tools Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rhino-tools-dev?hl=en
-~----------~----~----~----~------~----~------~--~---