hi

another question:
there is number of tags: n = len(tags)
and there is 
rows = db(data.id==link.record_id)\
    (link.tag_id.belongs(subquery)).select(
    data.ALL,
    orderby=data.id,
    groupby=data.id,
    having=data.id.count()==n)

so, if i have data1 with tags (news, sport) and data2 with tags (news, 
sport, football)
and searching for tags: news, sport

is the result data1 only or data1 and data2
if later, how to search for data with exactly entered tags (omit data with 
more tags)

andrej

On Monday, September 24, 2012 5:57:35 PM UTC+2, andrej burja wrote:
>
> hi
>
> it works
> thank you
>
> andrej
>
> On Sunday, September 23, 2012 12:18:32 AM UTC+2, Massimo Di Pierro wrote:
>>
>> Looks like postgres is picky and wants in groupby all the selected fields 
>> in distinct. This should work:
>>
>> rows = db(data.id==tag.record_id)\
>>     (tag.name.belongs(tags)).select(
>>        data.ALL,
>>        orderby=data.id,
>>        groupby=data.id|data.value,
>>        distinct=True)
>>
>> On Saturday, 22 September 2012 15:00:07 UTC-5, andrej burja wrote:
>>>
>>> the code with problem:
>>>
>>> rows = db(data.id==tag.record_id)\
>>>     (tag.name.belongs(tags)).select(
>>>        data.ALL,
>>>        orderby=data.id,
>>>        groupby=data.id,
>>>        distinct=True)
>>>
>>>
>>>
>>> On Saturday, September 22, 2012 10:26:27 AM UTC+2, andrej burja wrote:
>>>>
>>>> hi 
>>>>
>>>> i would like to use idea in book Application Development Cookbook - 
>>>> Efficienty search by tag. 
>>>> there are two functions: 'search_or' and 'search_and'
>>>> everything is working fine on sqlite
>>>> when i switch to postgres, there seems to be problem with 'groupby'. 
>>>> i got an error 
>>>>
>>>> <class 'psycopg2.ProgrammingError'> column "data.value" must appear in 
>>>> the GROUP BY clause or be used in an aggregate function LINE 1: SELECT 
>>>> DISTINCT data.id, data.value FROM tag, data WHERE ((d... ^
>>>> when i remove 'groupby=....id" there is no error, but (of course) 
>>>> 'search_and' function doesn't work properly
>>>>
>>>> is this a bug related to postgres?
>>>>
>>>> andrej
>>>>
>>>

-- 



Reply via email to