Log table and multi tennant

Hi,

I don’t see a field owner_id in de (Servoy) log table (multi tennant ?!), so I added that one myself. Next problem is that I can’t get it filled. I tried the auto-enter and the insert-event on the log table but they both don’t seem to work. I would like that field filled in stead of querying through relations to all other tables with the not so nice formatted pk-field in the log table.

Any ideas / comments ?

Lambert.

Every entry in the log table will have a user UUID, usually users are linked to Owners so you can simply use that relation to filter the Log table.

Thanks Nicola !

I forgot all about the user id…

Lambert.

Hi Nicola,

The user_uid in the log table is of type text and the user_id in the user table is of type integer…

Is that a problem in Servoy relations ?

Lambert.

Yes, that is a problem indeed.
I guess that you have implemented your own Users table and so you have two options: you can add a UUID column to your users table or you can add a column called “user_name” to your Log table (Servoy will automatically fill the username).
To filter the table at login time have a look at the databaseManager.addTableFilterParam(), once the filter is set it will persist for the entire session.

Nicola,

I only need one place in my solution to view all the log records of my current owner_id.
I’ll throw in that form the sql-power (of foundset.loadrecords()) where I can do the text-integer conversion of the log table user-uuid field.

Example sql statement I use now : select log.log_id from log ,sec_user us where us.user_id=idf_to_integer(log.user_uid) and us.owner_id=?

where idf_to_integer() is our own written database-dependent user defined function for text-integer conversion.

This way I don’t have to change (hurt) my data model…

What do you think of it ?

Lambert.

That is the way to go.

Not sure, but you probably don’t even have to do the type conversion in this instance.

You can keep the db indipendance if you use a simple servoy calc of the type TEXT:

userstable.user_uuid = " return user_id; "

and use that for the relation.

Thank you both Nicola and David !

Good to see the Servoy-developer (forum) community is so active…