Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 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
6e32569
Added missing RootNamespace in csprojs
roji Dec 21, 2013
a5a057e
Added EF6 ConnectionFactory class
roji Dec 21, 2013
c0f3877
Fix loading of embedded NpgsqlMetaData.xml
roji Dec 21, 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
559486f
Merge remote-tracking branch 'glenebob/fulltext_operator_fix'
jjchiw Dec 22, 2013
409a820
Add rootnamespace to NpgsqlProviderManifest
jjchiw Dec 22, 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
2 changes: 2 additions & 0 deletions 2 Npgsql.EntityFramework/Npgsql.EntityFramework.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AssemblyName>Npgsql.EntityFramework</AssemblyName>
<RootNamespace>Npgsql</RootNamespace>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Npgsql.snk</AssemblyOriginatorKeyFile>
Expand Down Expand Up @@ -97,6 +98,7 @@
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<Compile Include="NpgsqlConnectionFactory.cs" />
<Compile Include="NpgsqlServices.cs" />
<Compile Include="NpgsqlProviderManifest.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
Expand Down
1 change: 1 addition & 0 deletions 1 Npgsql.EntityFramework/Npgsql.EntityFrameworkLegacy.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AssemblyName>Npgsql.EntityFrameworkLegacy</AssemblyName>
<RootNamespace>Npgsql</RootNamespace>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Npgsql.snk</AssemblyOriginatorKeyFile>
Expand Down
21 changes: 21 additions & 0 deletions 21 Npgsql.EntityFramework/NpgsqlConnectionFactory.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System.Data.Common;
using System.Data.Entity.Infrastructure;

namespace Npgsql
{
/// <summary>
/// Instances of this class are used to create DbConnection objects for Postgresql
/// </summary>
public class NpgsqlConnectionFactory : IDbConnectionFactory
{
/// <summary>
/// Creates a connection for Postgresql for the given connection string.
/// </summary>
/// <param name="nameOrConnectionString">The connection string.</param>
/// <returns>An initialized DbConnection.</returns>
public DbConnection CreateConnection(string nameOrConnectionString)
{
return new NpgsqlConnection(nameOrConnectionString);
}
}
}
6 changes: 3 additions & 3 deletions 6 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
1 change: 1 addition & 0 deletions 1 Npgsql/Npgsql.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<AssemblyName>Npgsql</AssemblyName>
<RootNamespace>Npgsql</RootNamespace>
<FileAlignment>512</FileAlignment>
<SignAssembly>true</SignAssembly>
<AssemblyOriginatorKeyFile>..\Npgsql.snk</AssemblyOriginatorKeyFile>
Expand Down
81 changes: 46 additions & 35 deletions 81 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
19 changes: 17 additions & 2 deletions 19 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,26 @@ 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;

string fieldNameUnderScore = ConvertToUnderscore(fieldName);
if(field_name_index_table.TryGetValue(fieldNameUnderScore, out ret)
|| caseInsensitiveNameIndexTable.TryGetValue(fieldNameUnderScore, 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");

}

private string ConvertToUnderscore(string val)
{
return Regex.Replace(val, @"(\p{Ll})(\p{Lu})", "$1_$2");
}
}

Expand Down
2 changes: 1 addition & 1 deletion 2 Npgsql/Npgsql/NpgsqlSchema.cs
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ from pg_catalog.pg_constraint pgc
internal static DataTable GetDataSourceInformation()
{
DataSet ds = new DataSet();
using (Stream xmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Npgsql.NpgsqlMetaData.xml"))
using (Stream xmlStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("Npgsql.Npgsql.NpgsqlMetaData.xml"))
{
ds.ReadXml(xmlStream);
}
Expand Down
13 changes: 13 additions & 0 deletions 13 Npgsql/policy.2.0.Npgsql.config
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Npgsql"
publicKeyToken="5d8b90d52f46fda7"
culture="neutral" />
<bindingRedirect oldVersion="2.0.0.0-2.0.12.0"
newVersion="2.0.13.91"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
28 changes: 28 additions & 0 deletions 28 Npgsql/policyFileBuild.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
@if "%WindowsSdkDir%"=="" goto NO_WIN_SDK

@setlocal

@set net20out=bin\policies\net20
@set net40out=bin\policies\net40

@if not exist %net20out% mkdir %net20out%
@if not exist %net40out% mkdir %net40out%

@set aldir=%WindowsSdkDir_35%

:: If dev env is VS2010, then another path should be used.
@if "%aldir%"=="" set aldir=%WindowsSDKDir%\Bin

@"%aldir%\al.exe" /nologo /link:policy.2.0.Npgsql.config /out:%net20out%\policy.2.0.Npgsql.dll /keyfile:Npgsql\Npgsql.snk
@"%aldir%\NETFX 4.0 Tools\al.exe" /nologo /link:policy.2.0.Npgsql.config /out:%net40out%\policy.2.0.Npgsql.dll /keyfile:Npgsql\Npgsql.snk
@goto :EOF

:NO_WIN_SDK
@echo ==========================================================
@echo ERROR:
@echo Please make sure that an environment variable WindowsSdkDir_35 is set.
@echo This variable should point to the SDK dir which contains al.exe for clr 2.0.
@echo You can set this variable with launching command shell via Windows SDK Comamnd
@echo Prompt or Visual Studio Command Prompt.
@echo ==========================================================
@pause
18 changes: 18 additions & 0 deletions 18 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 27 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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.