Oracle Schema Name - Case Sensative

Posts   
 
    
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 01-Mar-2012 22:46:26   

I am using LLBLGen v3.1, SQL 2008 & Oracle 11i.

How should i handle case sensitive for oracle schema name?

e.g. If user types lower case schema name and llblgen sends request with that name oracle fails to give results. Is there is anyway in llblgen to specify case in sensitive for schema name and user name?

Rishi

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 02-Mar-2012 06:20:22   

Are your oracle schema names all in UPPERCASE? If so, why not converting the user input to uppercase?

LLBLGen emits the schema names surrounded by "" to make it possible case sensitivity. This can't be customized. If this is crucial, you could create a derived class of OracleSpecificCreator and override the CreateObjectName method so you can get rid of the "" in the schema. You then must also create a new version of DataAccessAdapter and DQE that uses this new custom specific creator. It is not much code but it's not trivial either. Let us know if you want to go through this path so we can assist you. I would rather try to find another solution, like validating the user input. I think that making the DB insensitive won't be an option for your DBA, as it's like that for a reason.

David Elizondo | LLBLGen Support Team
Otis avatar
Otis
LLBLGen Pro Team
Posts: 39909
Joined: 17-Aug-2003
# Posted on: 02-Mar-2012 11:24:41   

You use the typed in name for schema name overwriting? How do you use the typed in name as schema name?

Frans Bouma | Lead developer LLBLGen Pro
Rishi
User
Posts: 69
Joined: 31-Oct-2011
# Posted on: 02-Mar-2012 21:58:25   

I am overwriting schema name through code. This value is coming from web.config, there is a chance that user type wrong schema name. Is there any better way to handle this kind of situation.

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 04-Mar-2012 21:39:27   

This is the solution I talked about:

Put this code in a file in your DBSpecific generated project:

using System;
using System.Data;
using SD.LLBLGen.Pro.DQE.Oracle;
using SD.LLBLGen.Pro.ORMSupportClasses;
using System.Text;

// change this namespace to your own
namespace HR.LLBL.MSOracle.Adapter.v31.DatabaseSpecific
{
    /// <summary>
    /// Custom DataAccessAdapter that avoid case sensitive quereis
    /// </summary>
    public partial class DataAccessAdapterInsensitive : DataAccessAdapter
    {
        /// <summary>
        /// Return our custom DQE
        /// </summary>
        /// <returns></returns>
        protected override DynamicQueryEngineBase CreateDynamicQueryEngine()
        {
            return new DynamicQueryEngineInsensitive();
        }

    }
}

namespace SD.LLBLGen.Pro.DQE.Oracle
{
    /// <summary>
    /// Custom OracleSpecificCreator that avoids case sensitive aliases
    /// </summary>
    public class OracleSpecificCreatorInsensitive : OracleSpecificCreator
    {

        public OracleSpecificCreatorInsensitive()
            : base()
        {
        }

        public override string CreateValidAlias(string rawAlias)
        {
            return rawAlias;
        }
    }

    /// <summary>
    /// Custom DynamicQueryEngine that uses our custom OracleSpecificCreator
    /// </summary>
    public class DynamicQueryEngineInsensitive : DynamicQueryEngine
    {
        protected override IDbSpecificCreator CreateDbSpecificCreator()
        {
            return new OracleSpecificCreatorInsensitive();
        }
    }
}

Then in your own code use DataAccessAdapterInsensitive instead of DataAccessAdapter: var departments = new EntityCollection<DepartmentEntity>();

using (var adapter = new DataAccessAdapterInsensitive())
{
    adapter.FetchEntityCollection(departments, null);
}

I can't think about another solution other than validate the user input.

David Elizondo | LLBLGen Support Team