July 2018 Archives

Little Moose Bug

It is quick fix postette day here in the Moose-Pen

Yesterday I left off with one fail in my '30_where_basic.t' test case


# Expected SQL--> SELECT people.first_name First, people.last_name Last,
people.user_id "User ID"
# Generated SQL-> SELECT people.first_name, people.last_name, people.user_id
FROM people


my alias on these Elements

[
{

Moose Works Harder

Its move along day here in the Moose-Pen

Today I managed to get the time to create '25_exe_array.t' which tests DBI execute array and it went quite well. No real story on that one just with my new 'Test::Utils::sql_param_ok' function I was able to quickly expand it out from just 3 tests to 6 in a few minutes.

I then moved on to '30_where_basic.t' where the idea was to test the basic parts of a 'condition', The basic parts being simple single level predicates mixing elements, functions and expressions.

After creating some 64 tests and giving it a few goes to get rid o…

Little Moose Error

Its little bird day here in the Moose-Pen

How does that 'The Be Good Tanyas' song go?

And I sing, the littlest birds sing the prettiest songs …
For us Perl types it should be
And I swear, the littlest typos make the ugliest bugs ...

You will remember that I left off yesterday…

How much is too much Moose Testing

Its test test and test again day here in the Moose-pen

Today I added in over 70+ tests into '20_fields.t' and I went though almost every conflagration of fields, params, expression and functions I could think of even the expression from hell from this post.

I did today's work by the book meaning I did all the tests first then I did the debugging. Now I am not going to dump 450 plus lines of hash key value pairs here as that would really piss a few people off and I might loose a reader of two, as if an…

More Generic Moose

It is putter about some more day here in the Moose-Pen

I was puttering about today with my tests and I discovered something funny on some implications of SQL and it is to do with that 'AS' when playing with 'alias'. Now I knew it was an optional 'key-word' according to the SQL standard what I did not know is a number of DBs will syntax error when an optional key-word is used. So this SQL


SELECT sys_users.last_name AS last
FROM people AS sys_users

is correct to standard there are a number of DBs out there that o…

Very Short Moose

Its fix a but post-ette here in the Moose-Pen.

Yesterday I left off with this error;

Can't locate object method "alias" via package "Database::Accessor::Param"
GitHub\database-accessor-driver-dbi\lib/Database/Accessor/Driver/DBI.pm line 412.

So today I figure I better fix it.

For once in the Perl world the problem and error message are quite clear. Seem I never did add in the 'Database::Accessor::Roles::Alias' into th…

Moose Never Stops Testing

Its new test day again in the Moose-Pen

Well starting with the 20_fields.t test case today and this is really just this so far;


my $in_hash = {
da_compose_only => 1,
update_requires_condition => 0,
delete_requires_condition => 0,
view => { name => 'people' },
elements => [ { name => 'first_name', }, { name => 'last_name', }, ],
};
my $container = {
last_name => 'Bloggings',
first_name => 'Bill',
};
my $tests = [

A litle Big Moose forward

It carry on testing developing day here in the Moose-Pen.

I left off yesterday with a new Test::Utils->sql_param_ok sub that is going to save a good deal of coding effort as I move forward once I get all the tests up to the new standard of curse, (one foot forward one and a half steps back)

Today I am going to carry on with alias testing this time I am checking basic field alias. To accomplish this I changed the 'elements' in my $in_hash to ones with field aliases;

="pr…

Better Moose Testing

Its go back and fix day here in the Moose-Pen

In a recent post I mentioned that I went out and read though a number of SQL syntax books to make sure I was doing things correctly in which SQL clauses (Where, Sort, Link) goes where. That go me to thinking was the system I was using to test the SQL on a real DB using standard SQL?

Normally I test with Oracle App Express as it work well on a Windows box and has a nice UI but I just noticed that I have some odd SQL in one of my test cases 15_alias.t;

I was starting with this hash;

/users/byterock/2018/07/index.html

Moose Back on Track Again

It back to coding here in the Moose-Pen

About a week ago I had this rather obtuse SQL expression;

(abs((people.salary + .05) * 1.5))*people.overtime+(abs(people.salary+.05) *2)*people.doubletime)

for testing parentheses. I figured I might as well re-use that little snippet of code else where as it is valid SQL anywhere you would use a 'field'.

One very odd place to use it would be in a sort if you want to order a list by how much over time and double time a person earned. So I added a new test to my '60_order_by.t' case;

/users/byterock/2018/07/index.html

big Moose Done Tests (for now)

Still stuck in test mode here in the Moose-Pen.

Today I am re-writing the '47_dynamic_gathers.t' test. Looking at the code I cannot really use any of it as my Gather concept moved from two array-refs (gathers,filters) to just a singleton of 'Gather' made up of, elements and condtions.

The test is a little simpler now as all I have to test for is when I add a 'gather' the 'elements' and 'conditions' are correctly passed down from the DA to the DAD and when I add another 'gather' the current one is overridden by the new one;

To start I created two gathers;

/users/byterock/2018/07/index.html

Big Moose Tests Back

Well it tests everything again day here in the Moose-Pen

Is been almost two weeks since I started mucking about with Accessor.pm again trying to get my inherited views, parentheses, and conditions all in a row before I pass them down to the DA and now that I have things I think all settled I it time again fro me got go back and re-run the test suite to see if I did not bugger too much up.

This time out I did not fair that bad


Test Summary Report
-------------------
t/33_conditions.t (Wstat: 1024 Tests: 12 Failed: …

Even More Moose Attributes

Its extend API a little more Day here in the Moose-Pen

Since I was playing about with the API by adding in 'default_condition' for conditions I figured I might as well do the same for condition 'operator'. In my little abstract world the 'operator' is what I use to compare the 'left' and 'right' parts of a predicate.

Well first thing some tests;


$da = Database::Accessor->new($in_hash3);
ok($da->default_operator('!='),'Change Default operator to !=');
$da->retrieve( Data::Test->new());
ok(
$da->result->e…

More Moose Attibutes

It new attribute day here in the Moose-Pen.

Just a quick postette here today. I was thinking that it might be a good idea if I expanded my Database::Accessor API a little and give the end user the option of specifying a different 'default' condition that the present 'AND'.

As a good programmer I first added in a test;


$da = Database::Accessor->new($in_hash3);
ok($da->default_condition('OR'),'Change Defalut condition to OR');
$da->retrieve( Data::Test->new());
ok(
$da->result->error->gather->conditions->…

Mostly Tested Moose

Its get nowhere day here in the Moose-Pen

So I was all set to for today's post to move from playing with Database::Accessor and start playing with Driver::DBI again but just as I was finishing off the tests which I did not want to bore you with I got this:


...
ok 7 - Balanced parentheses
no ok 8 - AND not added to first gather condition predicate
ok 9 - AND added to last gather condition predicate

ok 26 - AND not present on first link predicate
not ok 27 - AND not present on first link predicate
not ok 28 - AN…

Ever More Testy Moose

It is go back again day here in the Moose-pen

In my last bunch of posts I though I had finally got all my element view, parentheses and 'AND' ; checking coming out all OK so I started today by going back to here I left off in Driver::DBI. The first thing I did was re-run the test suite and I ran into this

#   Failed test 'Where with function and 1 param SQL correct'
#   at D:\GitHub\database-accessor-driver-dbi\t\lib/Test/Utils.pm line 56.
# Expected SQL--> SELECT people.first_name, people.last_name, people.user_id
 FROM people WHERE length(people.last_name) = ?
# G…

Testy Moose

It test review day again here in the Moose-Pen

Today I was having a look at coverage that the '58_parenthes.t' test case gives and with only seven tests it is rather sparse, time to add a few more in.

What I want to first improve is the coverage for 'functions' and 'expressions' to make sure the nested nature or the left and right attributes are correct. I started with this formula 'element' make up of a number of 'expressions','functions', 'params' and 'elements' that use parentheses;

(abs((People.salary + .05) * 1.5))*People.overtime+(abs(Peop…

Moose Fix Bracket And AND

It is fix a bracket and AND day in the Moose-pen

I did a little more checking of my tests in '58_parenthes.t' and it would appear that my changes from yesterday's post did not actually do the trick as the second test is failing and the 'Condition' part of the has is in error;


conditions => [
{
left => {
name => 'First_1',
view => 'People'
},
right …

Bracket the Moose

It condiment day again here in the Moose-Pen

Time to do some more catch-up coding as my most recent round of changes to fix all my 'element->view' woes I ended up removing any checks for 'parentheses' I had in place. To recap on the original idea of the parentheses check was to make sure that there was at least one closing bracket for each opening bracket in the 'conditions' being send down to the DAD.

As it stands now I am using the '_parentheses_check' sub to check all the attributes that that may contains not just an 'element' but any class that can use a 'predicate' so …

Moose Troubles

Another quick fix postette today in the Moose-Pen

Yesterday I had my gather test fail with;


ok 46 - Second Gather element does not inherit view
not ok 47 - Third Gather element inherits view


and a

Can't call method "predicates" on an undefined value at 57_dad_elements.t line 486.
# Looks like your test exited with 255 just after 49.


A quick check of the test and the input and found a 'condtions' where I should have had a 'conditions' so that fixed t…

About byterock

user-pic Long time Perl guy, a few CPAN mods allot of work on DBD::Oracle and a few YAPC presentations