Commit 9e5bee47 authored by Nigel Kukard's avatar Nigel Kukard

Added _property_id support so we can reliable get the ID property

parent 60e2a1b0
......@@ -222,6 +222,11 @@ Below is a list of supported options:
=over
=item *
B<DATAOBJ_PROPERTY_ID>
This is the unique ID property of the object, only ONE of these can be specified!
=item *
B<DATAOBJ_PROPERTY_NOLOAD>
......@@ -1204,7 +1209,8 @@ sub _init
$self->{'_options'} = 0;
$self->{'_relations'} = { };
$self->{'_relations_map'} = { };
$self->{'_properties'} = {};
$self->{'_properties'} = { };
$self->{'_property_id'} = undef;
# If we have an odd number of params, chop off the first one as our options
if (@params % 2) {
......@@ -1218,6 +1224,19 @@ sub _init
$self->_log(DATAOBJ_LOG_DEBUG2," - Processing property '%s'",$propertyName);
# Process options if we have any
if (defined(my $options = $propertyConfig->{'options'})) {
# Check if this is an ID property, if it is, set the internal attribute
if ($options & DATAOBJ_PROPERTY_ID == DATAOBJ_PROPERTY_ID) {
if (defined($self->{'_property_id'})) {
$self->_log(DATAOBJ_LOG_ERROR,
"Multiple properties with DATAOBJ_PROPERTY_ID set, ignoring for property '%s'",$propertyName);
} else {
$self->{'_property_id'} = $propertyName;
}
}
}
# Check format of property
if (!($propertyName =~ /^[A-Z][A-Za-z0-9]+$/)) {
$self->_log(DATAOBJ_LOG_ERROR,"Property '%s' has an invalid name",$propertyName);
......@@ -1443,6 +1462,17 @@ sub _error
# Return the DATAOBJ_PROPERTY_ID property
sub _property_id
{
my $self = shift;
return $self->{'_property_id'};
}
# Return the property hash of a given property
sub _propertyByName
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment