[RDBO] multi level relationships?

2006-02-20 Thread Michael Lackhoff
Hi, I wonder if there is a shortcut for multi level relationships. I have three tables in a relationship like 'cities', 'states' and 'countries'. Now I would like to say something like print $city-country-name; I know how to to it in two steps (first get the state then the country from there)

[RDBO] cannot find sets that are clearly there

2006-02-20 Thread Michael Lackhoff
Hello again, I just started a project with Rose::DB::Object and I must say I am very impressed. It is really great! But still, I run into one or the other problem. I hope it is o.k. to ask these beginner questions. At the moment something drives me crazy that can be destilled to these few

[RDBO] Re: cannot find sets that are clearly there

2006-02-21 Thread Michael Lackhoff
Hello again, I found out about my problem from yesterday. It was all (well almost) my fault. In the database definition I had forgotten the 'INTEGER' qualifier but in the class definition everything was all right. Now these two didn't fit together and I got these mysterious effects. I say

Re: [RDBO] Re: cannot find sets that are clearly there

2006-02-21 Thread Michael Lackhoff
On 21 Feb 2006, John Siracusa wrote: SQLite really has no concept of SQL data types. Well, it has a very simplified concept, anyway. All that detail you put in your CREATE TABLE statements is pretty much ignored by SQLite. Instead, it stores everything as strings and integers (and maybe

Re: [RDBO] Object data as hash ref (was: cannot find sets that are clearly there)

2006-02-27 Thread Michael Lackhoff
On 21 Feb 2006, John Siracusa wrote: Thanks for your answer and sorry for my late reply, I couldn't work on my project for a few days. Ah, okay. For the record, I use an object-based approach to this kind of thing by using Rose::HTML::Objects to manage my forms. Anyway, getting a hashref

Re: [RDBO] sorted relationship output?

2006-03-14 Thread Michael Lackhoff
On 14 Mar 2006, John Siracusa wrote: On 3/14/06 4:17 AM, Michael Lackhoff wrote: Is it possible to either define a default sort_by clause in the relationship definition See Uwe's earlier response for how to do this. Yes, that works great. Thanks! or when the relationship method

Re: [RDBO] sorted relationship output?

2006-03-14 Thread Michael Lackhoff
On 14 Mar 2006, Uwe Voelker wrote: $meta-relationships ( changes = {type = 'one to many', class= 'Changes', column_map = {ID = 'AUFTRAG'}, manager_args = {sort_by = 'CHANGES.DATUM DESC'},

[RDBO] negative relationships?

2006-03-24 Thread Michael Lackhoff
Say, I have two tables: vendors and products. Now I want a list of all the vendors that have no products yet. This can be seen from the products table if there are no records with the vendor_id of the vendor in question. Is this possible with a 'normal' manager method or with a relationship or

Re: [RDBO] negative relationships?

2006-03-25 Thread Michael Lackhoff
Hello John, I did some more testing, got it working but still don't understand everything. This should work: $vendors = Vendor::Manager-get_vendors( with_objects = [ 'products' ], query= [ 'products.vendor_id' = undef ]); Yes, this works fine. That

Re: [RDBO] negative relationships?

2006-03-25 Thread Michael Lackhoff
Just for the record, I found it. 'NOT EXISTS (SELECT * FROM products p WHERE p.vendor_id = id)'; $vendors = Vendor::Manager-get_vendors(clauses = [ $subselect ]); This doesn't work for me (result list is empty but should have two entries). If I change the $subselect to

Re: [RDBO] ANNOUNCE: Rose::DB::Object 0.70 released

2006-04-08 Thread Michael Lackhoff
On 4 Apr 2006, John Siracusa wrote: Rose::DateTime: 0.52 (04.04.2006) - John Siracusa [EMAIL PROTECTED] * Allow negative and fractional epoch values in parse_date(). * Fixed a bug in the -mm-dd date parsing that caused it to incorrectly match 10-digit

[RDBO] Problem with many to many relationship under mod_perl

2006-04-30 Thread Michael Lackhoff
Hello, I am trying to write an authorization handler in mod_perl and got a very strange behaviour. What I want to achieve is use the group memberships stored in a database that is handled by RDBO to restrict access to some parts of my application. This script works perfectly well when run

Re: [RDBO] Problem with many to many relationship under mod_perl (solved)

2006-05-01 Thread Michael Lackhoff
On 30 Apr 2006, John Siracusa wrote: I can't think of any reason this would behave any differently under mod_perl. You are right. Sorry, it was another one of these silly mistakes. I have two perl installations, one as a normal installation and another one that came with apache, this is the

[RDBO] How to copy an object?

2006-05-05 Thread Michael Lackhoff
Hello John, thanks for your help on my negative groups question. I used the manager method as you suggested and it is working fine now! But as you might have guessed by now I ran into a new problem. (By the way, if I am asking too many questions just stop me. Then I will only ask again when I

Re: [RDBO] How to copy an object?

2006-05-05 Thread Michael Lackhoff
On 5 May 2006, John Siracusa wrote: There's no way around copying every field when making a copy! :) That's just what RDBO's (undocumented) clone() method does. It's not documented because I'm not sure if it does everything that a clone method should do. You can be the first to try it and

Re: [RDBO] [semi-OT] Adding version control to RDBO objects

2006-05-29 Thread Michael Lackhoff
On 29 May 2006 at 13:21, Svilen Ivanov wrote: I would like to extend RDBO to support versioning of properties for each instance. To explain it better I will use analogy with CVS: * calling -save will make new revision of the object (cvs commit) * -load(id=1) will get by default

[RDBO] How to do hierarchical defaults right?

2006-09-05 Thread Michael Lackhoff
Hello, in my application I have a hierarchy of company, organisational unit and sub-unit. Some data should be configurable on every level but not compulsory on every level. If it is not defined for the sub-unit it should be taken from the unit and if it is not there from the company. An

Re: [RDBO] How to do hierarchical defaults right?

2006-09-06 Thread Michael Lackhoff
On 5 Sep 2006, John Siracusa wrote: As for the uniqueness issue, if the combination really is unique, then why not add a unique key to the database and the class? Then you can load() speculatively instead of doing a Manager query. That's what I was looking for. Thanks for the hint, I didn't

[RDBO] How to do locking with RDBO?

2006-12-05 Thread Michael Lackhoff
Hello, I need some pseudo-unique numbers like invoice numbers. They start every year with 1, so autoincrement won't work. My idea was to use a helper table with just just two fields 'year' and 'last_used_number'. Is it enough to create a two column unique key or would it be better to do something

Re: [RDBO] How to do locking with RDBO?

2006-12-05 Thread Michael Lackhoff
Hello John, many thanks for your help, the only part I don't understand is why I need a new DB object: sub generate_invoice_number { my $class = shift; my $db = My::DB-new; # Rose::DB subclass Why not just use the default here? my $num; eval {

Re: [RDBO] How to do locking with RDBO?

2006-12-05 Thread Michael Lackhoff
On 5 Dec 2006 at 11:02, Perrin Harkins wrote: You can usually do this kind of ++ thing in one INSERT...SELECT statement: INSERT INTO invoice (id) SELECT MAX(id)+1 FROM invoice; That's clever! Though it seems to slightly defeat the point in using RDBO: To have Perl, classes and methods

Re: [RDBO] Integration with Rose::HTML::Form

2007-01-31 Thread Michael Lackhoff
On 30 Jan 2007 at 17:00, John Siracusa wrote: id is in $session, which the form knows nothing about. But in most web app frameworks, there's usually some way to get at globally applicable data like the session, in which case it's reasonable for customer_from_form() to return you an object

Re: [RDBO] Integration with Rose::HTML::Form

2007-01-31 Thread Michael Lackhoff
On 31 Jan 2007 at 8:52, John Siracusa wrote: I don't use CGI::Application, so maybe I'm misunderstanding how it works, but how about a class method that returns the current CGI::Application object? e.g., MyWebSite-current_app(). You'd set it at the beginning of each request. Then, in your

[RDBO] Relationship with complex mapping

2007-05-11 Thread Michael Lackhoff
Hello, I had to change a relationship from a simple ID to ID relationship to one that also includes a second ID. Worse still the second ID is not a column in one of the relationship partners but has to be taken from a record two steps up the hierarchy. Perhaps I will change the table to

[RDBO] cache object for later use within a mod_perl request cycle

2007-06-20 Thread Michael Lackhoff
I am using Apache2::AuthCookie for my authentification and authorisation. For both I have to get the user record from the database. For authorisation I have to do an additional lookup for an ordinary item that is requested by the user. I need this record to check e.g. if the requested item

Re: [RDBO] cache object for later use within a mod_perl request cycle

2007-06-22 Thread Michael Lackhoff
On 22 Jun 2007 at 10:03, Perrin Harkins wrote: On 6/22/07, Michael Lackhoff [EMAIL PROTECTED] wrote: Thanks for the hint! This almost did it. Some tests showed that I had to use the connection-variant of pnotes in my setup: use Apache2::ConnectionUtil; # grab the connection object

[RDBO] How to get transactions right

2007-06-27 Thread Michael Lackhoff
Hello, I read quite a lot recently about Apache::DBI, transactions and the problems that might occur but I must say that I am more confused than before as to what this all means for my RDBO project. It is a web app with lots of database activity (read and write). So performance and data

[RDBO] missing column aliases in recent version(s)

2007-06-30 Thread Michael Lackhoff
Hello, I just stumbled upon a changed behaviour that causes my app to crash with RDBO 0.764 (works with 0.758). The problem occurs in a method that should give me all the groups a user (therapeut in my case) is not in: sub notingroups { my $self = shift; my $nr = $self-nr; # user id

Re: [RDBO] missing column aliases in recent version(s)

2007-07-02 Thread Michael Lackhoff
John Siracusa wrote: Okay, I've made the change in SVN. RDBO 0.765 will have tN table aliasing on by default, even for queries that only involve a single table. The new table_aliases Manager parameter can be used to force the old behavior. Thanks! -Michael

[RDBO] many to many to arbitrary tables?

2007-07-03 Thread Michael Lackhoff
Hello, I would like to have the possibility to link from one record to other records in many other tables, something like this: in table dates: id = 1 when = 2007-07-04 14:00 ... some more fields a mapping table would look like this: date_id = 1 link_id = 5 link_table = customers date_id = 1

[RDBO] How to register a db using DBI::Proxy?

2007-08-09 Thread Michael Lackhoff
Hello, I am trying to use Rose::DB for a new project that uses an Oracle database but the connection is done with DBI::Proxy (then I don't have to install DBD::Oracle on every machine that accesses the database) After reading the docs the best I could manage was this: My::DB-register_db(

[RDBO] Still fighting with transactions

2007-08-14 Thread Michael Lackhoff
Hello, I thought I understood how to organize several write operations within a transaction but it still doesn't work the way I do it. Here is what I have so far: In my base class: sub init_db { my $self = shift; my $db; if (not $self-my_db) { $self-my_db( MyApp::DB-new() );

Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Michael Lackhoff
On 14.08.2007 16:54 Perrin Harkins wrote: $db-begin_work; # Start transaction die Does it roll back?; $db-commit; I don't see any rollback there. It's a common practice to put an Well, my understandig was that if perl dies within a transaction it (or DBI) would do a rollback, from your

Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Michael Lackhoff
On 14.08.2007 17:50 Perrin Harkins wrote: do you have any pointer on how this is done (correctly)? $r-push_handlers(PerlCleanupHandler = sub { MyApp::DB-rollback(); }); Thanks! That's exactly what I needed. I found already that there is a PerlCleanupHandler directive in

Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Michael Lackhoff
On 14.08.2007 18:54 Perrin Harkins wrote: On 8/14/07, John Siracusa [EMAIL PROTECTED] wrote: The simplest way to do this is to leave everything as per the defaults, and just use Apache::DBI. Note that Apache::DBI also does the automatic rollback for you, but only if you have AutoCommit off

Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Michael Lackhoff
On 14.08.2007 20:20 Bill Moseley wrote: On Tue, Aug 14, 2007 at 11:57:27AM +0200, Michael Lackhoff wrote: my $db = MyApp::DB-new; $self-my_db($db); # a new db for a new transaction $db-begin_work; # Start transaction ... create two objects and save them ... die Does it roll back?; $db

Re: [RDBO] Still fighting with transactions

2007-08-14 Thread Michael Lackhoff
On 14.08.2007 20:34 John Siracusa wrote: On 8/14/07, Michael Lackhoff [EMAIL PROTECTED] wrote: $db-begin_work; my $obj = Products-new(db = $db); ... $obj-save; some_helper_that_uses_db(); # rollback here my $obj2 = Customers-new(db = $db); ... $obj2-save; $db-commit; When I ran

Re: [RDBO] How to register a db using DBI::Proxy?

2007-08-29 Thread Michael Lackhoff
On 09.08.2007 13:42 John Siracusa wrote: On 8/9/07 6:13 AM, Michael Lackhoff wrote: I get this error message: Attempt to change driver from 'oracle' to 'proxy' detected. The driver cannot be changed after object creation. at test02.pl line 8 Is it possible to persuade Rose::DB

[RDBO] Proxy working now but Oracle not quite

2007-08-29 Thread Michael Lackhoff
Hello, Shame on me, I had forgotten to add a mapping of the driver to the Oracle::Proxy class, now it is working. After I got the connection I first tried to use the loader to create all the classes for me but that didn't work. I don't know if the reason is the proxy or RDBO because I couldn't

[RDBO] More on Oracle::Proxy

2007-09-03 Thread Michael Lackhoff
Hello, I did some more tests and it looks as if everything works as it should but RDBO still gives an error. This is from a DBI-trace: - fetch= [ '[EMAIL PROTECTED]' 'ZBMED' 'K002054024' 'mysecret' ] row1 at Object.pm line 385 - rows= '0E0' at Object.pm line 387 - finish= 1 at

[RDBO] good way to handle empty fields?

2007-12-13 Thread Michael Lackhoff
Hello, perhaps this is related to the new undef_sets_null but I am not sure. The problem: I have some fields where it is important if they are empty or not. Now emptyness is not so easy in SQL as we all know, it could be '' or 0 or NULL. When I create a record with such a field, it is usually

Re: [RDBO] good way to handle empty fields?

2007-12-13 Thread Michael Lackhoff
On 13.12.2007 14:03 John Siracusa wrote: On Dec 13, 2007 4:24 AM, Michael Lackhoff [EMAIL PROTECTED] wrote: When I create a record with such a field, it is usually NULL but after some editing with the help of RHTMLO the empty field value could become '' when saved. I believe the latest

Re: [RDBO] good way to handle empty fields?

2007-12-14 Thread Michael Lackhoff
On 14.12.2007 09:21 Darren Duncan wrote: If you have a place that holds a value, it should always hold a value. If you don't know a value for a place or a value isn't applicable there, then the place shouldn't exist at all. The more correct way to do this which SQL supports is through

Re: [RDBO] good way to handle empty fields?

2007-12-15 Thread Michael Lackhoff
On 16.12.2007 02:05 John Siracusa wrote: On Dec 15, 2007 10:43 AM, Michael Lackhoff [EMAIL PROTECTED] wrote: I guess, what you are talking about is done here: $form-init_fields_with_cgi($self-query). What is $self in that line? My (CGI::)Application object. The whole thing ($self-query

Re: [RDBO] ANNOUNCE: Rose::DB::Object 0.7663 released

2008-02-05 Thread Michael Lackhoff
On 04.02.2008 21:41 John Siracusa wrote: More bug fixes that I didn't want to wait until the next major release. I get this test failure with 0.7663: Test Summary Report --- t/db-object-loader-8.t (Wstat: 65280 Tests: 19 Failed: 16) Failed test number(s): 4-19