[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: sql/Pg-database.sql FUNCTION person__get_my_entity_id()



I will follow your advice:
 the best approach is to create a user for out of LSMB operations and
add this user to the users-table

Maybe worth to be added to documentation?

Thanks,
Herman

2013/11/1 Chris Travers <..hidden..>:
>
>
>
> On Thu, Oct 31, 2013 at 12:43 PM, herman vierendeels
> <..hidden..> wrote:
>>
>> Hello,
>>
>> with more and more triggers in DB,
>> you hit problems , e.g. with audittrail, when doing
>> sql-work outside of ledgerSMB, e.g. psql
>>
>> person__get_my_entity_id() returning empty list
>>
>> Could we redefine function as to always receive default row?
>
>
> If you do that, then you will run into fkey violations since a lot of things
> like audit trails have foreign key constraints attached.
>
> I think the best approach is to create a LedgerSMB user for out of LSMB
> operations.  (My largest customer has at least one user account for
> automated tasks).
>
> In 1.4, we might want to change the fkey on the audit trail from
> person(entity_id) to entity(id) as tat would enable more flexible external
> user frameworks without sacrificing auditability.
>
> Note this attaches to the db user.
>>
>>
>> CREATE OR REPLACE FUNCTION person__get_my_entity_id() RETURNS INT AS
>> $$
>>  SELECT entity_id from users where username =  SESSION_USER union
>> select 1 order by 1 desc limit 1;
>> $$ LANGUAGE SQL;
>
>
> In general, if you are writing to the db, the audit trails should be
> preserved.
>
> Best Wishes,
> Chris Travers
>>
>>
>> Greetings,
>> Herman Vierendeels
>>
>>
>> ------------------------------------------------------------------------------
>> Android is increasing in popularity, but the open development platform
>> that
>> developers love is also attractive to malware creators. Download this
>> white
>> paper to learn more about secure code signing practices that can help keep
>> Android apps secure.
>>
>> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
>> _______________________________________________
>> Ledger-smb-devel mailing list
>> ..hidden..
>> https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel
>
>
>
>
> --
> Best Wishes,
> Chris Travers
>
> Efficito:  Hosted Accounting and ERP.  Robust and Flexible.  No vendor
> lock-in.
> http://www.efficito.com/learn_more.shtml
>
> ------------------------------------------------------------------------------
> Android is increasing in popularity, but the open development platform that
> developers love is also attractive to malware creators. Download this white
> paper to learn more about secure code signing practices that can help keep
> Android apps secure.
> http://pubads.g.doubleclick.net/gampad/clk?id=65839951&iu=/4140/ostg.clktrk
> _______________________________________________
> Ledger-smb-devel mailing list
> ..hidden..
> https://lists.sourceforge.net/lists/listinfo/ledger-smb-devel
>