[baseten-users] updating of SQL-views
Patrick De Visschere
pdvisschere at fulladsl.be
Sat Feb 13 12:58:19 EET 2010
Hello again,
Thanks for your suggestions, but first I'm still trying to find out
what the limitations are of the automatic updating mechanism.
In the example I've mentioned there was 1 table (A) and a view (V) of
that table. A contains a column which is calculated in postgresql.
As I've noticed this dependent column is not updated via the view V
and I understand from your answer that this is indeed not implemented.
I was a little bit surprised because I have another example, more
complicated, where it works anyway.
Suppose I move the dependent column to a separate table (B) with a one-
to-one between A and B and the view V now joining A and B.
In that case the dependent column of B is sometimes updated
automatically.
I can only guess why it sometimes works but not always: apparently a
one-to-one relationship is made (I guess by the assistant) between
the view V and one of the underlying tables (A and B). I guess that If
this relationship is to the dependent table B, then it's updated; if
it is to the main table A, it is not.
Does this make sense?
And if it does, is there a way to force one possibility over the other?
Regards,
P. De Visschere
On 9 Feb, 2010, at 12:37 AM, Tuukka Norri wrote:
> Hi and sorry about taking some time with this.
>
> Patrick De Visschere kirjoitti 30.1.2010 kello 15.37:
>> I have a single table and an SQL-view of that table; baseten is
>> connected to the view and the required SQL-RULES are present.
>> - when I make changes in the table with pgAdmin, these are not
>> shown in the Cocoa-views. This is probably normal since baseten is
>> connected to the SQL-view. I enabled also the underlying table with
>> the assistant but that makes no difference.
> Unfortunately the change notifications have been implemented in such
> a way that changes in underlying tables won't currently be noticed.
> We did experiment with cascading notifications but they turned out
> to be more problematic than what they were worth.
>
>> - let's say that 1 column of the table is the sum of 2 other
>> columns (the sum is calculated by PostgreSQL) ; when I make changes
>> in the Cocoa-views then the SQL-table is properly updated but the
>> sum never shows up in the Cocoa-view although it's value is
>> returned by the RETURNING clause in the SQL- view RULES.
> When updating views only the primary key values are fetched, so
> changing the rule won't help.
>
>> - The view also contains a running-total; should this also be
>> updated automatically by BaseTen in the Cocoa-views?
> I would expect that it won't be updated.
>
> I can only offer some workarounds to the problem. If the calculation
> is simple, you could write a custom getter with a matching
> +keyPathsForValuesAffecting<Key> method. You could also use key-
> value coding operators [1].
> Another
>
> option is to use key-value observing to get a notification when a
> column gets updated and call -[BXDatabaseObject faultKey:] with the
> name of the column that contains the calculation as the argument
> when that happens.
>
> [1] http://developer.apple.com/mac/library/documentation/cocoa/Conceptual/KeyValueCoding/Concepts/ArrayOperators.html
> --
> Best regards,
> Tuukka Norri
> MK&C
>
>
>
> _______________________________________________
> baseten-users mailing list
> baseten-users at lists.basetenframework.org
> http://lists.basetenframework.org/mailman/listinfo/baseten-users
More information about the baseten-users
mailing list