Database Operations

Application Transaction Context

Predicates

Case Insensitivity

You can use the modifiers option in a predicate to search collections on fields that do not have case insensitive field type. In the following example :ci is passed along to the wild call. Other options are :not for negated and :partial for prefix test.

pred << predicate.wild(:a_fld_name,"search criteria*",:ci)

Differences

Smallworld has functionality used internally for merge/post to determine differences between the alternatives.

Table Differences

In order to get the table differences you need to compare two alternatives. So for this example let's say we are going to compare the current and the parent alternatives. You will need to get a handle on the alternatives. Here is an example of getting the views needed for the GIS dataset.

current_view << gis-program_manager.databases[:gis]
parent_view << current_view.replicate(-1) # this gets a "replica" view or the parent alternative
base_view << current_view.replicate(:base)

You can use current_view.table_changes_to(parent_view) to get the list of table/collection names that have been changed.

Record Differences

Typically you will run the difference stream on the current collection and parent collection. You will need to get a handle on the 2 or 3 collections. If doing a basic what changed comparison, you could get away with the current alternative collection and the parent alternative collection. But you may want to compare to the base as well (The parent alternative as it was when you created/aligned/posted the current current alternative). Here are 2 examples on table/collection named street and using the above views.

# Basic comparison of the parent & current views
diff_strm << ds_difference_stream.new_on(current_view.collections[:street],parent_view.collections[:street])
(change,curr_rec,base_rec,new_rec) << diff_strm.get()
diff_strm.close()
# Comparison of the parent, current, and base views
diff_strm << ds_difference_stream.new_on(current_view.collections[:street],
                                         base_view.collections[:street],
                                         parent_view.collections[:street])
(change,curr_rec,base_rec,new_rec) << diff_strm.get()
diff_strm.close()
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License