Oracle and a batch of fixed IndexOf* Tests

2 views
Skip to first unread message

Ardekantur

unread,
Sep 14, 2008, 12:32:16 AM9/14/08
to DbLinq
Hello all -

Puttering through some of the tests for Oracle and caught a fairly
simple fix for a couple of tests. Where the default SQL provider users
`STRPOS` for getting the right behavior from #IndexOf LINQ queries,
Oracle has INSTR and SUBSTR.

Thus:

Index: src/DbLinq.Oracle/OracleSqlProvider.cs
===================================================================
--- src/DbLinq.Oracle/OracleSqlProvider.cs (revision 876)
+++ src/DbLinq.Oracle/OracleSqlProvider.cs (working copy)
@@ -92,5 +92,28 @@
@"SELECT * FROM ({3}{0}{3}) WHERE {2} > {1}",
GetLiteralLimit(select, offsetAndLimit), offset,
LimitedRownum, NewLine);
}
+
+ protected override string GetLiteralStringIndexOf(string
baseString, string searchString, string startIndex, string count)
+ {
+ // SUBSTR(baseString, StartIndex)
+ string substring = GetLiteralSubString(baseString,
startIndex, count);
+
+ // INSTR(SUBSTR(baseString, StartIndex), searchString) ---
> range 1:n , 0 => doesn't exist
+ return string.Format("INSTR({0},{1})", substring,
searchString);
+ }
+
+ protected override string GetLiteralStringIndexOf(string
baseString, string searchString, string startIndex)
+ {
+ // SUBSTR(baseString,StartIndex)
+ string substring = GetLiteralSubString(baseString,
startIndex);
+
+ // INSTR(SUBSTR(baseString, StartIndex), searchString) ---
> range 1:n , 0 => doesn't exist
+ return string.Format("INSTR({0},{1})", substring,
searchString);
+ }
+
+ protected override string GetLiteralStringIndexOf(string
baseString, string searchString)
+ {
+ return GetLiteralSubtract(string.Format("INSTR({0},{1})",
baseString, searchString), "1");
+ }
}
}

This knocks out 5 more tests, I think. I may write some more just to
make sure we're hitting as many cases as we can.

Pablo Iñigo Blasco

unread,
Sep 14, 2008, 5:56:35 AM9/14/08
to dbl...@googlegroups.com


On Sun, Sep 14, 2008 at 6:32 AM, Ardekantur <Matthew....@gmail.com> wrote:

Hello all -

Hi Matthew!
 

It seems to be fine. The main potential problem you should consider here is the 'indexes start offset' difference between pl-sql and clr. Most of sql-engine has as first array index = 1. In the other hand, clr and most of programming languages has as first array index = 0. If you have considered it, it shoud be ok.


This knocks out 5 more tests, I think.

Great :-D
 
I may write some more just to
make sure we're hitting as many cases as we can.

That would be fantastic, they would be reused by others vendors too.

I have tried apply the patch over the Oracle folder, but it crashes, wich revision are you using? could you send an attached .patch file?

Regards.

Pascal Craponne

unread,
Sep 14, 2008, 8:07:35 AM9/14/08
to dbl...@googlegroups.com
Hi guys,

Matthew, are you interested in joining the team? You could commit your changes on your own.

Pablo, Matthew, regarding the 0/1 start index, that's a good point, and we have two options:
1. give to each potentially problematic SQL generation method both values, the one where index starts at 0, the other where index starts at 1.
2. add some characteristics to the ISqlProvider, telling if string indexes start at 0 or 1, for example.

What's you favorite flavor?
--
Pascal.

jabber/gtalk: pas...@jabber.fr
msn: pas...@craponne.org

Matthew Snyder

unread,
Sep 14, 2008, 8:23:57 AM9/14/08
to dbl...@googlegroups.com

On Sep 14, 2008, at 8:07 AM, Pascal Craponne wrote:

> Hi guys,
>
> Matthew, are you interested in joining the team? You could commit
> your changes on your own.

I would be delighted to join the team and help out where I can. I've
attached a diff of my changes regardless in case someone else wants to
confirm the test passes before that.

oracle_index_of_fixes.diff

Pascal Craponne

unread,
Sep 14, 2008, 11:30:01 AM9/14/08
to dbl...@googlegroups.com
Done.
Welcome to our new contributor, Matthew Snyder :)
You can now commit your own changes.


Since you join the project now, here's a brief development status:
- A few core features are missing (outer joins, references loading, lazy loading)
- Most of engine is in the core, the vendors are left as small as possible: we want new database support to be easily done.
- We're on our way to be Mono's Linq-to-SQL engine (and that is a pride!)
- After this, we'll probably add some specific features, but isolate them, in order to keep compatility with Mono (we have to build modes, strict [==Mono] and extended [DbLinq and specific features])

> Pablo, Matthew, regarding the 0/1 start index, that's a good point,
> and we have two options:
> 1. give to each potentially problematic SQL generation method both
> values, the one where index starts at 0, the other where index
> starts at 1.
> 2. add some characteristics to the ISqlProvider, telling if string
> indexes start at 0 or 1, for example.

I would definitely say the second choice. An override string,
something like Option Base in Visual Basic :-)
> --~--~---------~--~----~------------~-------~--~----~
>  This message is part of the topic "Oracle and a batch of fixed
> IndexOf*
> Tests" in the Google Group "DbLinq" for which you requested email
> updates.
> To stop receiving email updates for this topic, please visit the topic
> at http://groups.google.com/group/dblinq/t/b8c211c03d16d2db
> -~----------~----~----~----~------~----~------~--~---
>


Matthew Snyder

unread,
Sep 14, 2008, 2:14:26 PM9/14/08
to dbl...@googlegroups.com
Thanks for the effort, Pascal! I'll do my best.

I was curious about the lazy/reference loading since I didn't see it
working. I just assumed I was doing something wrong. It'll be great to
help in any way I can.

Pablo Iñigo Blasco

unread,
Sep 15, 2008, 7:56:47 AM9/15/08
to dbl...@googlegroups.com
On Sun, Sep 14, 2008 at 5:30 PM, Pascal Craponne <pic...@gmail.com> wrote:
> Since you join the project now, here's a brief development status:
> - A few core features are missing (outer joins, references loading, lazy
> loading)

I would like to add to that list a couple of things:

- Grouping capabilities: most of this feature is theoretically
implemented but it isn't working at all.

- Complex projections: projections which contains associations
accesses (AKA EntityRefs & EntitySets) or nested queries.
Example:
db.Orders.Select(o=>new {o.Employee, o.OrderDetails,
o.OrderDetails.Select(od=> od.ProductID});

Regards.

Andrus

unread,
Sep 15, 2008, 8:21:54 AM9/15/08
to dbl...@googlegroups.com
> I would like to add to that list a couple of things:

I tried pre-sugar DbLinq with MONO SVN.

DataContext constructor causes not implemented exception at line

Mapping = mappingSource.GetModel(GetType());

Fortunately, Mapping is not used anywhere in DbLinq code. So I was able to
fix this by removing this line.

It seems that for MONO metadata access implementation is required.

Andrus.

Pascal Craponne

unread,
Sep 15, 2008, 8:23:42 AM9/15/08
to dbl...@googlegroups.com
Grouping WAS working, at least on SQLite. The feature needs to be finished, but I can swear it was working.

Pascal Craponne

unread,
Sep 15, 2008, 8:28:11 AM9/15/08
to dbl...@googlegroups.com
In Sugar DbLinq, the MetaModel is implemented... Poorly (only attributes, and only needed parts), but implemented.
Reply all
Reply to author
Forward
0 new messages