X Tutup
Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
346e5cc
Accept operator @@ for full text search queries
jjchiw Dec 6, 2013
f1f4149
Find FieldIndex where column name use _
jjchiw Dec 6, 2013
f734a88
Issue #116 - Tests
jjchiw Dec 12, 2013
ea76d68
update from upstream - issue #116 Tests
jjchiw Dec 12, 2013
d60e12a
Merge remote-tracking branch 'upstream/master'
jjchiw Dec 13, 2013
8be9316
#116 Tests in NpgsqlTests Project
jjchiw Dec 13, 2013
b41e734
#116 fixing references
jjchiw Dec 13, 2013
3bdb8c1
#116 Removing App.config
jjchiw Dec 13, 2013
8b6638a
#116 removing the key file from the tests folder
jjchiw Dec 13, 2013
6d41b32
#116 Add to app.config <remove invariant="Npgsql"/>
jjchiw Dec 13, 2013
2b8325a
#116 ConvertToUnderscoreCase if the first comparison fails
jjchiw Dec 16, 2013
e6d784e
Merge remote-tracking branch 'upstream/master'
jjchiw Dec 20, 2013
af0548a
Windows integrated security #if directive for mono
jjchiw Dec 20, 2013
025201f
Revert "Windows integrated security #if directive for mono"
jjchiw Dec 21, 2013
c1613b7
Merge remote-tracking branch 'upstream/release-2.1.0'
jjchiw Dec 21, 2013
19876b2
NpgsqlCommand.AppendCommandReplacingParameterValues() and operators @…
glenebob Dec 21, 2013
33cae49
Accept operator @@ for full text search queries
jjchiw Dec 6, 2013
478c00d
Find FieldIndex where column name use _
jjchiw Dec 6, 2013
6f52b65
Issue #116 - Tests
jjchiw Dec 12, 2013
452d403
#116 Tests in NpgsqlTests Project
jjchiw Dec 13, 2013
08a349f
#116 fixing references
jjchiw Dec 13, 2013
8638212
#116 Removing App.config
jjchiw Dec 13, 2013
b326be2
#116 removing the key file from the tests folder
jjchiw Dec 13, 2013
5a07ecb
#116 Add to app.config <remove invariant="Npgsql"/>
jjchiw Dec 13, 2013
1efb8fd
#116 ConvertToUnderscoreCase if the first comparison fails
jjchiw Dec 16, 2013
615c4a0
Windows integrated security #if directive for mono
jjchiw Dec 20, 2013
87291a9
Revert "Windows integrated security #if directive for mono"
jjchiw Dec 21, 2013
6a5a9d2
Fixing rootnamespace
jjchiw Dec 23, 2013
35238a6
Merge remote-tracking branch 'upstream/master'
jjchiw Dec 23, 2013
4e83e97
Merge branch 'master' of https://github.com/jjchiw/Npgsql
jjchiw Dec 23, 2013
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Npgsql.EntityFramework/NpgsqlProviderManifest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Npgsql
internal class NpgsqlProviderManifest : DbXmlEnabledProviderManifest
{
public NpgsqlProviderManifest(string serverVersion)
: base(CreateXmlReaderForResource("NpgsqlProviderManifest.Manifest.xml"))
: base(CreateXmlReaderForResource("Npgsql.NpgsqlProviderManifest.Manifest.xml"))
{
}

Expand All @@ -26,11 +26,11 @@ protected override XmlReader GetDbInformation(string informationType)

if (informationType == StoreSchemaDefinition)
{
xmlReader = CreateXmlReaderForResource("NpgsqlSchema.ssdl");
xmlReader = CreateXmlReaderForResource("Npgsql.NpgsqlSchema.ssdl");
}
else if (informationType == StoreSchemaMapping)
{
xmlReader = CreateXmlReaderForResource("NpgsqlSchema.msl");
xmlReader = CreateXmlReaderForResource("Npgsql.NpgsqlSchema.msl");
}

if (xmlReader == null)
Expand Down
81 changes: 46 additions & 35 deletions Npgsql/Npgsql/NpgsqlCommand.Rewrite.cs
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,8 @@ private enum TokenType
None,
Quoted,
Param,
Colon
Colon,
FullTextMatchOp
}

/// <summary>
Expand All @@ -579,6 +580,7 @@ private void AppendCommandReplacingParameterValues(Stream dest, string src, int
int currTokenBeg = begin;
int currTokenLen = 0;
Dictionary<NpgsqlParameter, int> paramOrdinalMap = null;
int end = begin + length;

if (prepare)
{
Expand All @@ -590,7 +592,7 @@ private void AppendCommandReplacingParameterValues(Stream dest, string src, int
}
}

for (int currCharOfs = begin ; currCharOfs < begin + length ; currCharOfs++)
for (int currCharOfs = begin ; currCharOfs < end ; currCharOfs++)
{
char ch = src[currCharOfs];

Expand All @@ -602,7 +604,7 @@ private void AppendCommandReplacingParameterValues(Stream dest, string src, int
case TokenType.None :
switch (ch)
{
case '\'':
case '\'' :
if (currTokenLen > 0)
{
dest.WriteString(src.Substring(currTokenBeg, currTokenLen));
Expand All @@ -615,7 +617,8 @@ private void AppendCommandReplacingParameterValues(Stream dest, string src, int

break;

case ':':
case ':' :
if (currTokenLen > 0)
{
dest.WriteString(src.Substring(currTokenBeg, currTokenLen));
}
Expand All @@ -627,20 +630,21 @@ private void AppendCommandReplacingParameterValues(Stream dest, string src, int

break;

case '@':
case '<' :
case '@' :
if (currTokenLen > 0)
{
dest.WriteString(src.Substring(currTokenBeg, currTokenLen));
}

currTokenType = TokenType.Param;
currTokenType = TokenType.FullTextMatchOp;

currTokenBeg = currCharOfs + 1;
currTokenLen = 0;
paramMarker = '@';
currTokenBeg = currCharOfs;
currTokenLen = 1;

break;

default:
default :
currTokenLen++;

break;
Expand Down Expand Up @@ -705,12 +709,12 @@ private void AppendCommandReplacingParameterValues(Stream dest, string src, int
case TokenType.Quoted :
switch (ch)
{
case '\'':
case '\'' :
currTokenLen++;

break;

default:
default :
if (currTokenLen > 1 && lastChar == '\'')
{
dest.WriteString(src.Substring(currTokenBeg, currTokenLen));
Expand All @@ -734,40 +738,47 @@ private void AppendCommandReplacingParameterValues(Stream dest, string src, int
break;

case TokenType.Colon :
switch (ch)
if (IsParamNameChar(ch))
{
case ':':
currTokenLen++;

break;
currTokenType = TokenType.Param;

default:
if (currTokenLen == 1)
{
currTokenType = TokenType.Param;
currTokenBeg = currCharOfs;
currTokenLen = 0;
paramMarker = ':';

currTokenBeg = currCharOfs;
currTokenLen = 0;
paramMarker = ':';
}
else
{
dest.WriteString(src.Substring(currTokenBeg, currTokenLen));
// Re-evaluate this character
goto ProcessCharacter;
}
else
{
// Demote to the unknown token type and continue.
currTokenType = TokenType.None;
currTokenLen++;
}

currTokenType = TokenType.None;
break;

currTokenBeg = currCharOfs;
currTokenLen = 0;
}
case TokenType.FullTextMatchOp :
if (lastChar == '@' && IsParamNameChar(ch))
{
currTokenType = TokenType.Param;

// Re-evaluate this character
goto ProcessCharacter;
currTokenBeg = currCharOfs;
currTokenLen = 0;
paramMarker = '@';

// Re-evaluate this character
goto ProcessCharacter;
}
else
{
// Demote to the unknown token type and continue.
currTokenType = TokenType.None;
currTokenLen++;
}

break;


}

lastChar = ch;
Expand Down
8 changes: 6 additions & 2 deletions Npgsql/Npgsql/NpgsqlRowDescription.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using System.IO;
using System.Text;
using NpgsqlTypes;
using System.Text.RegularExpressions;

namespace Npgsql
{
Expand Down Expand Up @@ -196,12 +197,15 @@ public int TryFieldIndex(string fieldName)
public int FieldIndex(String fieldName)
{
int ret = -1;
if(field_name_index_table.TryGetValue(fieldName, out ret) || caseInsensitiveNameIndexTable.TryGetValue(fieldName, out ret))

if (field_name_index_table.TryGetValue(fieldName, out ret)
|| caseInsensitiveNameIndexTable.TryGetValue(fieldName, out ret))
return ret;
else if(_compatVersion < GET_ORDINAL_THROW_EXCEPTION)
else if (_compatVersion < GET_ORDINAL_THROW_EXCEPTION)
return -1;
else
throw new IndexOutOfRangeException("Field not found");

}
}

Expand Down
18 changes: 18 additions & 0 deletions tests/App.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<providers>
<provider invariantName="Npgsql" type="Npgsql.NpgsqlServices, Npgsql.EntityFramework" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="Npgsql" />
<add name="Npgsql Data Provider" invariant="Npgsql" description="Data Provider for PostgreSQL" type="Npgsql.NpgsqlFactory, Npgsql" />
</DbProviderFactories>
</system.data>
</configuration>
27 changes: 27 additions & 0 deletions tests/CommandTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3481,5 +3481,32 @@ public void DataTypeTests()
Assert.AreEqual(typeof(NpgsqlTimeTZ), result.GetType());
*/
}

[Test]
// Target NpgsqlCommand.AppendCommandReplacingParameterValues()'s handling of operator @@.
public void Operator_At_At_RewriteTest()
{
NpgsqlCommand cmd = new NpgsqlCommand("SELECT to_tsvector('fat cats ate rats') @@ to_tsquery('cat & rat')", Conn);

Assert.IsTrue((bool)cmd.ExecuteScalar());
}

[Test]
// Target NpgsqlCommand.AppendCommandReplacingParameterValues()'s handling of operator @>.
public void Operator_At_GT_RewriteTest()
{
NpgsqlCommand cmd = new NpgsqlCommand("SELECT 'cat'::tsquery @> 'cat & rat'::tsquery", Conn);

Assert.IsFalse((bool)cmd.ExecuteScalar());
}

[Test]
// Target NpgsqlCommand.AppendCommandReplacingParameterValues()'s handling of operator <@.
public void Operator_LT_At_RewriteTest()
{
NpgsqlCommand cmd = new NpgsqlCommand("SELECT 'cat'::tsquery <@ 'cat & rat'::tsquery", Conn);

Assert.IsTrue((bool)cmd.ExecuteScalar());
}
}
}
Loading
X Tutup