New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic property is case sensitive in Mono #421

Closed
kobruleht opened this Issue Nov 29, 2014 · 6 comments

Comments

Projects
None yet
4 participants
@kobruleht

kobruleht commented Nov 29, 2014

Dynamic property returned By webmatrix using Npgsql is case sensitive.

Steps to reproduce:

  1. Create ASP.NET MVC 4 application using Microsoft Webmatrix.Data.dll and Npgsql with controller:

    public ActionResult CaseTest()
    {
        using (var db = Database.OpenConnectionString(ConnectionString(),
        "Npgsql"))
        {
            var vaik = db.QuerySingle("select 'Test' as Test");
            return new ContentResult() { Content = vaik.Test };
        }
    }
    
    
    static string ConnectionString()
    {
        NpgsqlConnectionStringBuilder csb = new NpgsqlConnectionStringBuilder()
        {
            SearchPath = "public",
            Host = "localhost",
            Database = "postgres",
            UserName = "postgres",
        };
        return csb.ConnectionString;
    }
    
  2. Invoke controller CaseTest method in Linux

Observed:

[System.IndexOutOfRangeException]: Array index is out of range.
at System.Data.Common.DbDataRecordImpl.GetValue (int) <0x0005f>
at System.Data.Common.DbDataRecordImpl.get_Item (int) <0x00018>
at System.Data.Common.DbDataRecordImpl.get_Item (string) <0x00027>
at WebMatrix.Data.DynamicRecord.get_Item (string) <0x00030>
at WebMatrix.Data.DynamicRecord.TryGetMember (System.Dynamic.GetMemberBinder,object&) <0x0002b>
at (wrapper dynamic-method) object.CallSite.Target (System.Runtime.CompilerServices.Closure,System.Runtime.CompilerServices.CallSite,object) <0x000e9>
at My.Controllers.ReportController.CaseTest () <0x001d3>
at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[]) <0x00045>
at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc.ControllerBase,object[]) <0x0002d>
at System.Web.Mvc.ReflectedActionDescriptor.Execute (System.Web.Mvc.ControllerContext,System.Collections.Generic.IDictionary`2<string, object>) <0x001ff>
at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor,System.Collections.Generic.IDictionary`2<string, object>) <0x00033>
at System.Web.Mvc.Async.AsyncControllerActionInvoker.InvokeSynchronousActionMethod (System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor,System.Collections.Generic.IDictionary`2<string, object>) <0x00023>
at System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41 () <0x0001f>
at System.Web.Mvc.Async.AsyncResultWrapper/<>c__DisplayClass8`1<System.Web.Mvc.ActionResult>.<BeginSynchronous>b__7 (System.IAsyncResult) <0x00019>
at System.Web.Mvc.Async.AsyncResultWrapper/WrappedAsyncResult`1<System.Web.Mvc.ActionResult>.End () <0x0005a>
at System.Web.Mvc.Async.AsyncResultWrapper.End<System.Web.Mvc.ActionResult> (System.IAsyncResult,object) <0x0003b>
at System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod (System.IAsyncResult) <0x00027>
at System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c__DisplayClass37/<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33 () <0x0007e>
at System.Web.Mvc.Async.AsyncControllerActionInvoker/<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49 () <0x00038>

Expected:

controller should return Test

In .NET 4 in Windows it produces expected result.

@franciscojunior

This comment has been minimized.

Show comment
Hide comment
@franciscojunior

franciscojunior Dec 1, 2014

Member

Hi, @kobruleht !

Are you able to create a simple command line program which reproduces this problem? This would help us create a testcase for the problem which in turn would help us solve it.

Thanks in advance.

Member

franciscojunior commented Dec 1, 2014

Hi, @kobruleht !

Are you able to create a simple command line program which reproduces this problem? This would help us create a testcase for the problem which in turn would help us solve it.

Thanks in advance.

@kobruleht

This comment has been minimized.

Show comment
Hide comment
@kobruleht

kobruleht Dec 1, 2014

I'm using free Visual Studio Express 2013 For Web . I havent found a way to create console application with it. Probably simple console application containing commands

using (var db = Database.OpenConnectionString(ConnectionString(),
"Npgsql"))
{
var vaik = db.QuerySingle("select 'Test' as Test");
string x = vaik.Test;
Console.WriteLine(x);
}

reproduces the issue.

kobruleht commented Dec 1, 2014

I'm using free Visual Studio Express 2013 For Web . I havent found a way to create console application with it. Probably simple console application containing commands

using (var db = Database.OpenConnectionString(ConnectionString(),
"Npgsql"))
{
var vaik = db.QuerySingle("select 'Test' as Test");
string x = vaik.Test;
Console.WriteLine(x);
}

reproduces the issue.

@Emill

This comment has been minimized.

Show comment
Hide comment
@Emill

Emill Dec 1, 2014

Member

PostgreSQL's lexer converts unquoted identifiers to lower case, so your query is equivalent to select 'Test' as test

What you probably want is

select 'Test' as "Test"

Member

Emill commented Dec 1, 2014

PostgreSQL's lexer converts unquoted identifiers to lower case, so your query is equivalent to select 'Test' as test

What you probably want is

select 'Test' as "Test"

@franciscojunior

This comment has been minimized.

Show comment
Hide comment
@franciscojunior

franciscojunior Dec 1, 2014

Member

Does it work if you use the following query:

"select 'Test' as "Test" ";

If so, I think Mono is using the table alias as the name of the property in
the same casing it is returned from the server.

The only workaround you can do is to use your identifiers between double
quotes where Postgresql will use the case you provided. In this case
postgresql would return a table called Test instead of test if used without
quotes.

I think you should open an issue report on Mono repository about that issue.

I hope it helps.

On Mon, Dec 1, 2014 at 4:15 PM, kobruleht notifications@github.com wrote:

I'm using free Visual Studio Express 2013 For Web . I havent found a way
to create console application with it. Probably simple console application
containing commands

using (var db = Database.OpenConnectionString(ConnectionString(),
"Npgsql"))
{
var vaik = db.QuerySingle("select 'Test' as Test");
return new ContentResult() { Content = vaik.Test };
}

reproduces the issue.


Reply to this email directly or view it on GitHub
#421 (comment).

Regards,

Francisco Figueiredo Jr.
Npgsql Lead Developer
http://www.npgsql.org
http://gplus.to/franciscojunior
http://fxjr.blogspot.com
http://twitter.com/franciscojunior

Member

franciscojunior commented Dec 1, 2014

Does it work if you use the following query:

"select 'Test' as "Test" ";

If so, I think Mono is using the table alias as the name of the property in
the same casing it is returned from the server.

The only workaround you can do is to use your identifiers between double
quotes where Postgresql will use the case you provided. In this case
postgresql would return a table called Test instead of test if used without
quotes.

I think you should open an issue report on Mono repository about that issue.

I hope it helps.

On Mon, Dec 1, 2014 at 4:15 PM, kobruleht notifications@github.com wrote:

I'm using free Visual Studio Express 2013 For Web . I havent found a way
to create console application with it. Probably simple console application
containing commands

using (var db = Database.OpenConnectionString(ConnectionString(),
"Npgsql"))
{
var vaik = db.QuerySingle("select 'Test' as Test");
return new ContentResult() { Content = vaik.Test };
}

reproduces the issue.


Reply to this email directly or view it on GitHub
#421 (comment).

Regards,

Francisco Figueiredo Jr.
Npgsql Lead Developer
http://www.npgsql.org
http://gplus.to/franciscojunior
http://fxjr.blogspot.com
http://twitter.com/franciscojunior

@kobruleht

This comment has been minimized.

Show comment
Hide comment
@kobruleht

kobruleht Dec 1, 2014

@Emill .NET is not case sensitive in this case. So Mono shoud also case insensitive on this.
I entered it to https://bugzilla.xamarin.com/show_bug.cgi?id=24935

kobruleht commented Dec 1, 2014

@Emill .NET is not case sensitive in this case. So Mono shoud also case insensitive on this.
I entered it to https://bugzilla.xamarin.com/show_bug.cgi?id=24935

@roji

This comment has been minimized.

Show comment
Hide comment
@roji

roji May 8, 2016

Member

Revisiting after a long time, seems like this was caused by the mono bug above, which has been resolved and released a long time ago, closing.

Member

roji commented May 8, 2016

Revisiting after a long time, seems like this was caused by the mono bug above, which has been resolved and released a long time ago, closing.

@roji roji closed this May 8, 2016

@roji roji added the invalid label May 8, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment