Issue 190 in dblinq2007: Using wrong alias when joining tables

0 views
Skip to first unread message

dblin...@googlecode.com

unread,
Jan 31, 2010, 5:41:14 PM1/31/10
to dblin...@googlegroups.com
Status: New
Owner: ----

New issue 190 by vladislav.iofe: Using wrong alias when joining tables
http://code.google.com/p/dblinq2007/issues/detail?id=190

Using wrong alias when joining the same table.

ver0.19.

1. Create self-referencing entity with fields ID and IDParent
2. Insert two record into entity's table, the second entry references to
the first.
3. Run the code:
var query = (
from cf in dc.Folder
join cf2 in dc.Folder on cf.IDParent equals cf2.ID
select cf2
).Distinct();

var list = query.ToArray();

Expected: the first entity
Actual: empty list
Result SQL query:

SELECT DISTINCT cf2$.dt_created, cf2$.dt_modified, cf2$.full_path, cf2$.id,
cf2$.id_parent, cf2$.key_type, cf2$.name
FROM public.folder cf$, public.folder cf2$
WHERE (cf$.id_parent = cf$.id)


--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings

dblin...@googlecode.com

unread,
Mar 9, 2010, 11:11:12 PM3/9/10
to dblin...@googlegroups.com
Updates:
Status: Accepted
Labels: Type-Defect Component-SQLite Priority-Medium

Comment #1 on issue 190 by jonmpryor: Using wrong alias when joining tables
http://code.google.com/p/dblinq2007/issues/detail?id=190

For those like me who need an eagle eye, the problem is the final WHERE
clause -- the
alias name is wrong. It's:

WHERE (cf$.id_parent = cf$.id)

but should be:

WHERE (cf2$.id_parent = cf$.id)

dblin...@googlecode.com

unread,
Apr 1, 2012, 10:48:23 AM4/1/12
to dblin...@googlegroups.com

Comment #2 on issue 190 by tos.oliv...@gmail.com: Using wrong alias when
joining tables
http://code.google.com/p/dblinq2007/issues/detail?id=190

try to change, in the TableExpression.cs, the IsEqualTo method, to this:

public virtual bool IsEqualTo(TableExpression expression)
{
return (Name == expression.Name && JoinID == expression.JoinID
&&
(Alias == null || expression.Alias == null
|| Alias.Equals(expression.Alias)));
}

Reply all
Reply to author
Forward
0 new messages