Author: gbayon
Date: Sat May 31 06:52:05 2008
New Revision: 662026

URL: http://svn.apache.org/viewvc?rev=662026&view=rev
Log:
fix IBATISNET-267

Added:
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/ps_InsertAccountWithDefault.sql
Modified:
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/Account.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/account-init.sql
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildStatements.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ProcedureDeSerializer.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ParameterMapping/InlineParameterMapParser.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Dynamic/DynamicSql.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/SimpleDynamic/SimpleDynamicSql.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/ProcedureSql.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/StaticSql.cs
    
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Statements/PreparedStatementFactory.cs
    ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Apache.Ibatis.DataMapper.SqlClient.Test.2005.csproj
 Sat May 31 06:52:05 2008
@@ -198,6 +198,7 @@
     <Content Include="Scripts\petstore-drop.sql" />
     <Content Include="Scripts\petstore-init.sql" />
     <Content Include="Scripts\petstore-schema.sql" />
+    <Content Include="Scripts\ps_InsertAccountWithDefault.sql" />
     <Content Include="Scripts\ps_SelectAccount.sql" />
     <Content Include="Scripts\ps_SelectAccountWithOutPutParam.sql" />
     <Content Include="Scripts\ps_SelectAllAccount.sql" />

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/Account.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/Account.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/Account.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Domain/Account.cs
 Sat May 31 06:52:05 2008
@@ -18,6 +18,7 @@
                private bool _bannerOption = false;
                private bool _cartOption = false;
            private Document _document = null;
+        private bool? nullBannerOption = false;
 
         protected IList<Document> documents = new List<Document>();
 
@@ -79,7 +80,13 @@
                {
                        get { return _bannerOption; }
                        set { _bannerOption = value; }
-               }
+        }//nullBannerOption
+
+        public bool? NullBannerOption
+        {
+            get { return nullBannerOption; }
+            set { nullBannerOption = value; }
+        }
 
                public bool CartOption
                {

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Fixtures/Mapping/MSSQL/ProcedureTest.cs
 Sat May 31 06:52:05 2008
@@ -5,8 +5,7 @@
 using Apache.Ibatis.DataMapper.SqlClient.Test.Fixtures;
 using NUnit.Framework;
 using NUnit.Framework.SyntaxHelpers;
-using Apache.Ibatis.DataMapper.Session;
-using Apache.Ibatis.DataMapper.Session.Transaction;
+using System.Collections.Generic;
 
 namespace Apache.Ibatis.DataMapper.SqlClient.Test.Fixtures.Mapping.MSSQL
 {
@@ -35,6 +34,7 @@
             InitScript( sessionFactory.DataSource, ScriptDirectory + 
"ps_SelectAllAccount.sql", false);                            
             InitScript( sessionFactory.DataSource, ScriptDirectory + 
"swap-procedure.sql" );
             InitScript(sessionFactory.DataSource, ScriptDirectory + 
"ps_SelectAccountWithOutPutParam.sql");
+            InitScript(sessionFactory.DataSource, ScriptDirectory + 
"ps_InsertAccountWithDefault.sql");
         }
 
         /// <summary>
@@ -48,6 +48,99 @@
 
         #region Specific statement store procedure tests for sql server
 
+        [Test]
+        public void Procedure_with_inline_parameter_should_work()
+        {
+            // parameter syntax
+            
//@{propertyName,column=string,type=string,dbype=Varchar,direction=Input,nullValue=N/A,handler=string}
+
+            Account account = 
dataMapper.QueryForObject<Account>("SPWithInlineParameter", 1);
+            Assert.AreEqual(1, account.Id);
+        }
+
+        [Test]
+        public void Procedure_with_inline_output_parameter_should_work()
+        {
+            Hashtable map = new Hashtable();
+            map.Add("Account_ID", 1);
+            map.Add("OutPut", 0);
+            Account account = 
dataMapper.QueryForObject<Account>("SPWithInlineParameterAndOutPutParam", map);
+
+            Assert.That(map["OutPut"], Is.EqualTo(987));
+
+            AssertAccount1(account);
+        }
+
+        [Test]
+        public void Procedure_with_complex_inline_parameter_should_work()
+        {
+            Account account = new Account();
+
+            account.Id = 99;
+            account.FirstName = "Achille";
+            account.LastName = "Talon";
+            account.EmailAddress = "[EMAIL PROTECTED]";
+            account.CartOption = false;
+
+            dataMapper.Insert("InsertAccountViaStoreProcedure", account);
+
+            Account testAccount = 
dataMapper.QueryForObject<Account>("GetAccountViaColumnName", 99);
+
+            Assert.IsNotNull(testAccount);
+            Assert.That(testAccount.Id, Is.EqualTo(99));
+            Assert.That(testAccount.EmailAddress, Is.EqualTo("[EMAIL 
PROTECTED]"));
+            Assert.That(testAccount.CartOption, Is.False);
+        }
+
+        [Test]
+        public void Procedure_with_default_parameter_should_work()
+        {
+            Account account = new Account();
+
+            account.Id = 99;
+            account.FirstName = "Achille";
+            account.LastName = "Talon";
+
+            dataMapper.Insert("InsertAccountViaSPWithDefaultParameter", 
account);
+
+            Account testAccount = 
dataMapper.QueryForObject<Account>("GetAccountViaColumnName", 99);
+
+            Assert.IsNotNull(testAccount);
+            Assert.That(testAccount.Id, Is.EqualTo(99));
+            Assert.That(testAccount.EmailAddress, Is.EqualTo("[EMAIL 
PROTECTED]"));
+            Assert.That(testAccount.BannerOption, Is.False);
+            Assert.That(testAccount.CartOption, Is.False);
+        }
+
+        [Test]
+        public void Procedure_with_dynamic_parameter_should_work()
+        {
+            Account account = new Account();
+
+            account.Id = 99;
+            account.FirstName = "Achille";
+            account.LastName = "Talon";
+            account.NullBannerOption = false;
+
+            dataMapper.Insert("InsertAccountViaSPWithDynamicParameter", 
account);
+
+            Account testAccount = 
dataMapper.QueryForObject<Account>("GetAccountViaColumnName", 99);
+
+            Assert.IsNotNull(testAccount);
+            Assert.That(testAccount.Id, Is.EqualTo(99));
+            Assert.That(testAccount.EmailAddress, Is.EqualTo("[EMAIL 
PROTECTED]"));
+            Assert.That(testAccount.BannerOption, Is.False);
+            Assert.That(testAccount.CartOption, Is.False);
+
+            account.Id = 100;
+            account.FirstName = "Achille";
+            account.LastName = "Talon";
+            account.NullBannerOption = null;
+
+            dataMapper.Insert("InsertAccountViaSPWithDynamicParameter", 
account);
+
+        }
+
         /// <summary>
         /// Test XML parameter.
         /// </summary>

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Maps/Account.xml
 Sat May 31 06:52:05 2008
@@ -786,9 +786,10 @@
                </procedure>
 
     <procedure id="SelectAllAccountViaSP" resultClass="Account">
-      ps_SelectAllAccount
+      ps_SelectAllAccount 
     </procedure>
 
+    
     <procedure id="SelectAccountViaXML" parameterMap="XML-params" 
resultClass="Account">
       ps_SelectByIdList
     </procedure>
@@ -797,6 +798,44 @@
       ps_SelectAccountWithOutPutParam
     </procedure>
     
+    <procedure id="SPWithInlineParameter" parameterClass="int" 
resultClass="Account">
+      ps_SelectAccount @{Account_ID,column=Account_ID}
+    </procedure>
+
+    <procedure id="SPWithInlineParameterAndOutPutParam" parameterClass="map" 
resultClass="Account">
+      ps_SelectAccountWithOutPutParam @{Account_ID,column=Account_ID}, 
@{OutPut,column=OutPut}
+    </procedure>
+
+    <procedure id="InsertAccountViaSPAndInlineParameter" parameterClass="map" >
+      ps_InsertAccount
+      @{Id,column=Account_ID},
+      @{FirstName,column=Account_FirstName},
+      @{LastName,column=Account_LastName},
+      @{EmailAddress,column=Account_Email,[EMAIL PROTECTED],
+      @{BannerOption,column=Account_Banner_Option,dbType=Varchar,type=bool},
+      @{CartOption,column=Account_Cart_Option,handler=HundredsBool}
+    </procedure>
+
+    <procedure id="InsertAccountViaSPWithDefaultParameter" 
parameterClass="map" >
+      ps_InsertAccountWithDefault
+      @{Id,column=Account_ID},
+      @{FirstName,column=Account_FirstName},
+      @{LastName,column=Account_LastName},
+      @{EmailAddress,column=Account_Email,[EMAIL PROTECTED]
+    </procedure>
+
+    <procedure id="InsertAccountViaSPWithDynamicParameter" 
parameterClass="map" >
+      ps_InsertAccountWithDefault
+      @{Id,column=Account_ID}
+      ,@{FirstName,column=Account_FirstName}
+      ,@{LastName,column=Account_LastName}
+      ,@{EmailAddress,column=Account_Email,[EMAIL PROTECTED]
+      <isNotNull property="NullBannerOption">
+      
,@{NullBannerOption,column=Account_Banner_Option,dbType=Varchar,type=bool}
+      </isNotNull>
+      @{CartOption,column=Account_Cart_Option,handler=HundredsBool}
+    </procedure>
+    
        </statements>
 
        <parameterMaps>

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/account-init.sql
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/account-init.sql?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/account-init.sql
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/account-init.sql
 Sat May 31 06:52:05 2008
@@ -55,3 +55,6 @@
 if exists (select * from dbo.sysobjects where id = 
object_id(N'[dbo].[ps_SelectAccountWithOutPutParam]') and 
 OBJECTPROPERTY(id, N'IsProcedure') = 1)
 drop procedure [dbo].[ps_SelectAccountWithOutPutParam]
+
+if exists (select * from dbo.sysobjects where id = 
object_id(N'[dbo].[ps_InsertAccountWithDefault]') and OBJECTPROPERTY(id, 
N'IsProcedure') = 1)
+drop procedure [dbo].[ps_InsertAccountWithDefault]
\ No newline at end of file

Added: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/ps_InsertAccountWithDefault.sql
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/ps_InsertAccountWithDefault.sql?rev=662026&view=auto
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/ps_InsertAccountWithDefault.sql
 (added)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper.SqlClient.Test.2005/Scripts/ps_InsertAccountWithDefault.sql
 Sat May 31 06:52:05 2008
@@ -0,0 +1,12 @@
+CREATE PROCEDURE dbo.[ps_InsertAccountWithDefault]
[EMAIL PROTECTED]  [int], 
[EMAIL PROTECTED] [nvarchar](40),
[EMAIL PROTECTED] [varchar](32),
[EMAIL PROTECTED] [varchar](128),
[EMAIL PROTECTED] [varchar](255)='Non',
[EMAIL PROTECTED] [int] =200
+AS
+insert into Accounts  
+(Account_ID, Account_FirstName, Account_LastName, Account_Email, 
Account_Banner_Option, Account_Cart_Option) 
+values 
+(@Account_ID, @Account_FirstName, @Account_LastName, @Account_Email, 
@Account_Banner_Option, @Account_Cart_Option)
\ No newline at end of file

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildStatements.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildStatements.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildStatements.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/ModelBuilder/BuildStatements.cs
 Sat May 31 06:52:05 2008
@@ -50,6 +50,8 @@
     public partial class DefaultModelBuilder
     {
         private readonly InlineParameterMapParser paramParser = new 
InlineParameterMapParser();
+        private const string MARK_TOKEN = "?";
+        private const string COMMA_TOKEN = ",";
 
         /// <summary>
         /// Builds the mapped statements.
@@ -383,7 +385,7 @@
                     sql = new ProcedureSql(
                         modelStore.DataExchangeFactory,
                         modelStore.DBHelperParameterCache,
-                        newSql, 
+                        newSql.Replace(MARK_TOKEN, 
string.Empty).Replace(COMMA_TOKEN, string.Empty).Trim(), 
                         statement);
                     // Could not call BuildPreparedStatement for procedure 
because when NUnit Test
                     // the database is not here (but in theory procedure must 
be prepared like statement)

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ProcedureDeSerializer.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ProcedureDeSerializer.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ProcedureDeSerializer.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Configuration/Serializers/ProcedureDeSerializer.cs
 Sat May 31 06:52:05 2008
@@ -50,14 +50,21 @@
         {
             BaseDeserialize(modelStore, config);
 
-            if (parameterMap == null)
+            if (parameterClass!=null)
             {
-                parameterMap = 
modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP);
             }
+            else
+            {
+                if (parameterMap == null)
+                {
+                    parameterMap = 
modelStore.GetParameterMap(ConfigConstants.EMPTY_PARAMETER_MAP);
+                }                
+            }
+
 
             return new Procedure(
                 id,
-                null,
+                parameterClass,
                 parameterMap,
                 resultClass,
                 resultsMap,

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ParameterMapping/InlineParameterMapParser.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ParameterMapping/InlineParameterMapParser.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ParameterMapping/InlineParameterMapParser.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/ParameterMapping/InlineParameterMapParser.cs
 Sat May 31 06:52:05 2008
@@ -72,6 +72,9 @@
 
             if (sqlStatement.Contains(NEW_BEGIN_TOKEN))
             {
+                // V3 parameter syntax
+                
//@{propertyName,column=string,type=string,dbype=string,direction=[Input/Output/InputOutput],nullValue=string,handler=string}
+
                 if (newSql != null)
                 {
                     string toAnalyse = newSql;
@@ -84,9 +87,9 @@
                         string prepend = toAnalyse.Substring(0, start);
                         string append = toAnalyse.Substring(end + 
NEW_END_TOKEN.Length);
                        
-                        //EmailAddress,type=string,dbType=Varchar,[EMAIL 
PROTECTED]
+                        
//EmailAddress,column=string,type=string,dbType=Varchar,[EMAIL PROTECTED]
                         string parameter = toAnalyse.Substring(start + 
NEW_BEGIN_TOKEN.Length, end - start - NEW_BEGIN_TOKEN.Length);
-                        ParameterProperty mapping = NewParseMapping(parameter, 
parameterClassType, dataExchangeFactory);
+                        ParameterProperty mapping = NewParseMapping(parameter, 
parameterClassType, dataExchangeFactory, statement);
                         mappingList.Add(mapping);
                         newSqlBuffer.Append(prepend);
                         newSqlBuffer.Append(MARK_TOKEN);
@@ -130,7 +133,7 @@
                                                    } 
                                                    else 
                                                    {
-                                mapping = NewParseMapping(token, 
parameterClassType, dataExchangeFactory);
+                                mapping = NewParseMapping(token, 
parameterClassType, dataExchangeFactory, statement);
                                                    }                           
                                                                                
         
 
                                                    mappingList.Add(mapping);
@@ -177,11 +180,12 @@
         /// <param name="token">The token.</param>
         /// <param name="parameterClassType">Type of the parameter 
class.</param>
         /// <param name="dataExchangeFactory">The data exchange 
factory.</param>
+        /// <param name="statement">The statement.</param>
         /// <returns></returns>
         /// <example>
         /// 
#propertyName,type=string,dbype=Varchar,direction=Input,nullValue=N/A,handler=string#
         /// </example>
-        private ParameterProperty NewParseMapping(string token, Type 
parameterClassType, DataExchangeFactory dataExchangeFactory) 
+        private ParameterProperty NewParseMapping(string token, Type 
parameterClassType, DataExchangeFactory dataExchangeFactory,IStatement 
statement) 
                {
             string propertyName = string.Empty;
             string type = string.Empty;
@@ -189,6 +193,7 @@
             string direction = string.Empty;
             string callBack = string.Empty;
             string nullValue = null;
+            string columnName = string.Empty;
 
                        StringTokenizer paramParser = new 
StringTokenizer(token, "=,", false);
                        IEnumerator enumeratorParam = 
paramParser.GetEnumerator();
@@ -221,10 +226,14 @@
                                        else if ("handler".Equals(field)) 
                                        {
                         callBack = value;
-                                       } 
+                                       }
+                    else if ("column".Equals(field))
+                    {
+                        columnName = value;
+                    } 
                                        else 
                                        {
-                                               throw new 
DataMapperException("Unrecognized parameter mapping field: '" + field + "' in " 
+ token);
+                                               throw new 
DataMapperException("When parsing inline parameter for statement 
'"+statement.Id+"', can't recognize parameter mapping field: '" + field + "' in 
" + token+", check your inline parameter syntax.");
                                        }
                                } 
                                else 
@@ -235,7 +244,7 @@
 
             return new ParameterProperty(
                 propertyName,
-                string.Empty,
+                columnName,
                 callBack,
                 type,
                 dbType,

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Dynamic/DynamicSql.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Dynamic/DynamicSql.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Dynamic/DynamicSql.cs 
(original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Dynamic/DynamicSql.cs 
Sat May 31 06:52:05 2008
@@ -54,6 +54,8 @@
        /// </example>
        public sealed class DynamicSql : ISql, IDynamicParent  
        {
+        private const string MARK_TOKEN = "?";
+        private const string COMMA_TOKEN = ",";
 
                #region Fields
 
@@ -165,7 +167,12 @@
 
                        string dynSql = ctx.BodyText;
 
-                       // Processes $substitutions$ after DynamicSql
+            if (statement is Procedure)
+            {
+                dynSql = dynSql.Replace(MARK_TOKEN, 
string.Empty).Replace(COMMA_TOKEN, string.Empty).Trim();
+            }
+
+                   // Processes $substitutions$ after DynamicSql
                        if ( SimpleDynamicSql.IsSimpleDynamicSql(dynSql) ) 
                        {
                 dynSql = new SimpleDynamicSql(
@@ -325,7 +332,7 @@
                private PreparedStatement BuildPreparedStatement(ISession 
session, RequestScope request, string sqlStatement)
                {
             PreparedStatementFactory factory = new 
PreparedStatementFactory(session, dbHelperParameterCache, request, statement, 
sqlStatement);
-                       return factory.Prepare();
+                       return factory.Prepare(true);
                }
                #endregion
 

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/SimpleDynamic/SimpleDynamicSql.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/SimpleDynamic/SimpleDynamicSql.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/SimpleDynamic/SimpleDynamicSql.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/SimpleDynamic/SimpleDynamicSql.cs
 Sat May 31 06:52:05 2008
@@ -213,7 +213,7 @@
         private PreparedStatement BuildPreparedStatement(ISession session, 
RequestScope request, string sqlStatement)
                {
                        PreparedStatementFactory factory = new 
PreparedStatementFactory( session, dbHelperParameterCache, request, statement, 
sqlStatement);
-                       return factory.Prepare();
+                       return factory.Prepare(false);
                }
                #endregion
 

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/ProcedureSql.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/ProcedureSql.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/ProcedureSql.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/ProcedureSql.cs
 Sat May 31 06:52:05 2008
@@ -111,7 +111,7 @@
                                        if (preparedStatement==null)
                                        {
                         PreparedStatementFactory factory = new 
PreparedStatementFactory(session, dbHelperParameterCache, request, statement, 
commandText);
-                                               preparedStatement = 
factory.Prepare();
+                                               preparedStatement = 
factory.Prepare(false);
                                        }
                                }
                        }

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/StaticSql.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/StaticSql.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/StaticSql.cs 
(original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Sql/Static/StaticSql.cs 
Sat May 31 06:52:05 2008
@@ -103,7 +103,7 @@
                        RequestScope request = new RequestScope( 
dataExchangeFactory, session, statement);
 
             PreparedStatementFactory factory = new 
PreparedStatementFactory(session, dbHelperParameterCache, request, statement, 
sqlStatement);
-                       preparedStatement = factory.Prepare();
+                       preparedStatement = factory.Prepare(false);
                }
 
                #endregion

Modified: 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Statements/PreparedStatementFactory.cs
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Statements/PreparedStatementFactory.cs?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Statements/PreparedStatementFactory.cs
 (original)
+++ 
ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/Model/Statements/PreparedStatementFactory.cs
 Sat May 31 06:52:05 2008
@@ -105,10 +105,12 @@
                }
 
 
-               /// <summary>
-               /// Create a list of IDataParameter for the statement and build 
the sql string.
-               /// </summary>
-               public PreparedStatement Prepare()
+        /// <summary>
+        /// Create a list of IDataParameter for the statement and build the 
sql string.
+        /// </summary>
+        /// <param name="isDynamic">if set to <c>true</c> this statement is 
dynamic.</param>
+        /// <returns></returns>
+               public PreparedStatement Prepare(bool isDynamic)
                {
                        preparedStatement = new PreparedStatement();
 
@@ -132,7 +134,14 @@
                                {
                     if (dbProvider.UseDeriveParameters)
                                        {
-                        DiscoverParameter();
+                        if (isDynamic)
+                        {
+                            DiscoverParameter(request.ParameterMap);           
              
+                        }
+                        else
+                        {
+                            DiscoverParameter(statement.ParameterMap); 
+                        }
                                        }
                                        else
                                        {
@@ -186,7 +195,7 @@
         /// <summary>
         /// For store procedure, auto discover IDataParameters for stored 
procedures at run-time.
         /// </summary>
-        private void DiscoverParameter()
+        private void DiscoverParameter(ParameterMap parameterMap)
                {
                        // pull the parameters for this stored procedure from 
the parameter cache 
                        // (or discover them & populate the cache)
@@ -206,15 +215,15 @@
                                                dataParameter.ParameterName = 
dataParameter.ParameterName.Substring(start);
                                        }
                                }
-                               preparedStatement.DbParametersName.Add( 
dataParameter.ParameterName );
                                preparedStatement.DbParameters[i] = 
dataParameter;
                        }
                    
             // Re-sort DbParameters to match order used in the parameterMap
-            IDbDataParameter[] sortedDbParameters = new 
IDbDataParameter[commandParameters.Length];
-            for (int i = 0; i < statement.ParameterMap.Properties.Count; i++)
+            IDbDataParameter[] sortedDbParameters = new 
IDbDataParameter[parameterMap.Properties.Count];
+            for (int i = 0; i < parameterMap.Properties.Count; i++)
             {
-                sortedDbParameters[i] = Search(preparedStatement.DbParameters, 
statement.ParameterMap.Properties[i], i);
+                sortedDbParameters[i] = Search(preparedStatement.DbParameters, 
parameterMap.Properties[i], i);
+                
preparedStatement.DbParametersName.Add(sortedDbParameters[i].ParameterName);
             }
             preparedStatement.DbParameters = sortedDbParameters;
                }
@@ -230,7 +239,7 @@
                     {
                         if 
(parameterName.StartsWith(dbProvider.ParameterPrefix))
                         {
-                            int prefixLength = 
dbProvider.ParameterPrefix.Length;
+                           int prefixLength = 
dbProvider.ParameterPrefix.Length;
                            parameterName = 
parameterName.Substring(prefixLength);
                         }
                     }

Modified: ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd
URL: 
http://svn.apache.org/viewvc/ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd?rev=662026&r1=662025&r2=662026&view=diff
==============================================================================
--- ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd (original)
+++ ibatis/trunk/cs/V3/src/Apache.Ibatis.DataMapper/SqlMap.xsd Sat May 31 
06:52:05 2008
@@ -75,8 +75,30 @@
        </xs:element>
        <xs:element name="procedure">
                <xs:complexType mixed="true">
+                       <xs:choice minOccurs="0" maxOccurs="unbounded">
+                               <xs:element ref="include"/>
+                               <xs:element ref="selectKey"/>
+                               <xs:element ref="generate"/>
+                               <xs:element ref="dynamic"/>
+                               <xs:element ref="isEmpty"/>
+                               <xs:element ref="isEqual"/>
+                               <xs:element ref="isGreaterEqual"/>
+                               <xs:element ref="isGreaterThan"/>
+                               <xs:element ref="isLessThan"/>
+                               <xs:element ref="isLessEqual"/>
+                               <xs:element ref="isNotEmpty"/>
+                               <xs:element ref="isNotEqual"/>
+                               <xs:element ref="isNotNull"/>
+                               <xs:element ref="isNotParameterPresent"/>
+                               <xs:element ref="isNotPropertyAvailable"/>
+                               <xs:element ref="isNull"/>
+                               <xs:element ref="isParameterPresent"/>
+                               <xs:element ref="isPropertyAvailable"/>
+                               <xs:element ref="iterate"/>
+                       </xs:choice>
                        <xs:attribute name="id" type="xs:string" 
use="required"/>
                        <xs:attribute name="parameterMap" type="xs:string" />
+                       <xs:attribute name="parameterClass" type="xs:string" />
                        <xs:attribute name="resultMap" type="xs:string"/>
                        <xs:attribute name="resultClass" type="xs:string"/>
                        <xs:attribute name="cacheModel" type="xs:string"/>


Reply via email to