atk4 / data Goto Github PK
View Code? Open in Web Editor NEWData Access PHP Framework for SQL & high-latency databases
Home Page: https://atk4-data.readthedocs.io
License: MIT License
Data Access PHP Framework for SQL & high-latency databases
Home Page: https://atk4-data.readthedocs.io
License: MIT License
need to document how DSQL objects can be created by action()
Build integration with Read the docs service, so that our docs site are always up-date.
We must have the following features, all documented, tested and coded.
Collect and send Code Coverage statistics to CodeClimate.
It appears that the use of $join->id in reveres join is incorrect.
Look at this file: https://github.com/atk4/data/blob/develop/src/Join_SQL.php#L211
With reverse join you are joining like this:
$db->join('contact.user_id');
foreign_field
is user_id, and suppose user_id is 2. When you add new record, $join->id is set to lastInsertID:
$this->id = $insert->connection->lastInsertID();
so it holds the value of contact.id, let's say it's 1 for our new record. If you execute delete after, the where() clause can cause deletion of incorrect record:
$delete->where($this->foreign_field, $this->id);
which would render to "where user_id = 1".
Just a blank class with a single method that does nothing.
In my example I have table "Nominal" which is hierarchical. When I load it, I create an array like this:
"id" -> "path"
This is handy for be because now that when I'm reading from another model and it contain "id" value, I can look up full nominal path without worrying about number of selects.
I believe Agile Data can do this for me special join type. Here is how I'd like it to work:
$n = new Model_Nominal($db);
$assoc = $n->getPathAssociations(); // returns "id" -> "path"
// Next create a model
$nar = new Model($assoc));
// Test it
$nar->load(183);
echo $nar[$nar->title_field]; // will output path
$m = new Model_Report_Activity($db);
$m->join($nar, 'nominal_id')->addField('nominal_path');
foreach($m as $row) {
var_dump($row); // includes 'nominal_path' now
}
Using the ContainerTraits (http://agile-core.readthedocs.io/en/latest/overview.html#run-time-tree-containers) implement handling for fields:
ability to remove fields and to specify field class.
i need to refactor load(), loadBy() and loadAny() to merge them with tryLoad, tryLoadBy an tryLoadAny. But there are some considerations:
Given these conditions, I'm not sure who should call what. I'm thinking there should be an extra argument to Persistence->loadX that will indicate if the exception should be generated or if [] should be simply returned.
There are many validators out there. Here is one example: https://github.com/Respect/Validation
We need to provide a way how a user can integrate a validator package into his model. I'm sure it's done through hooks, but this needs to be tested.
Especially when we integrate with the UI library, validators would typically give you true/false values but it needs to appear as an error on the form.
Agile Data needs to have a well-defined way how to define validations that would be compatible with 3rd party validators.
Model object can target DataSet but one of those records can be active. Even before we implement link with the database drivers, we can implement work with current (active) record.
Need help reviewing and cleaning up any grammar errors in README file.
We will need actions in order to handle load() save() operations:
$m->saveAction()->execute(); // same as save();
Model would populate save action with modified (dirty) fields.
Correct syntax highlighter should be set in SQL blocks in docs.
http://build-me-the-docs-please.readthedocs.io/en/latest/Using_Sphinx/ShowingCodeExamplesInSphinx.html#showing-source-code-examples-in-sphinx
Integrate with Packagist and test dependencies.
We won't be implementing driver for Neo4j just yet, but I'd like to create a whitepaper guide on how to properly implement the Neo4j driver (best practices) for Agile Data.
The actual driver can either be done by @romaninsh or someone else by following the guide.
https://github.com/atk4/data/blob/develop/CONTRIBUTING.md - is out of date.
I have focused my effort on Array and SQL implementation, but MongoDB implementation is not even started. We should get it started and implement all the features that we have already added for MongoDB.
$this->hasOne('company_id', ['CompanyType', 'default'=>1]);
This does not properly pass default to the field. Worakround:
$this->hasOne('company_id', 'CompanyType');
$this->getElement('company_id')->default=1;
implement actions such as sum or avg.
When Agile Data is used in UI frameworks, then model definition will sometimes include UI properties. This is because Model and UI binding is often a seamless one-line process:
$grid->setModel(new Model_User($db));
and $grid needs to populate information based on model fields only. Here are a couple of things that UI framework will expect to be difined in the field:
$m->addField('birthdate', ['type'=>'date', 'ui'=>'DatePicker', 'caption'=>'Birth Date']);
We need a document explaining what is the standard way to implement UI properties.
The point of this test is to make sure that insert works well and not failing randomly. Note that relations in AD are optional.
In most cases when user is trying to save " John Smith" he actually means "John Smith". It's just an accidental space, but that can cause trouble.
The same can be said for the numbers "394,283.03" and booleans "Y" / "N".
The process of converting user-supplied values that are "almost good" into an actually good input is called Normalisation. Agile Data needs to have a well-defined way to handle normalization.
Implement the initial data drivers for PDO / MySQL and Array.
Currently using hasOne() and hasMany() you can define related models. That's cool, but sometimes you want to add a custom relation.
Basically when calling $m->ref('AuditLog'); it would respond with a related model. Technically you could create a method $m->getAuditLog(); but we want to keep all relations separate in case we want to iterate through them (for example by visualising in UI or exploring relations).
Here is invocation:
$m->addRelation('AuditLog', function($m) {
return (new Model_Audit($big_data_db))->addCondition('user_id', $m->id);
});
And usage after:
$log = $m->load(123)->ref('AuditLog');
$log->addAction(..);
or in UI framework:
$crud->addRef('AuditLog');
I defined model like this:
class Model_Transfer extends Model {
public $table='doc';
function init() {
parent::init();
$this->addField('amount');
$this->pmt = $this->join('payment.doc_id');
$this->pmt->hasOne('account_id', 'Model_Account');
$this->pmt->hasOne('tronsfer_payment_id', 'Model_Transfer');
}
function createPayment($account2, $amount)
{
$leg2 = clone $this;
$leg2['account_id'] = $account2->id;
$leg2['amount'] = $amount;
$leg2->save();
$this['amount'] = -$amount;
$this['transfer_payment_id'] = $leg2->id;
$this->save();
$leg2['transfer_payment_id'] = $this->id;
$leg2->save(); // BUG IN THIS LINE
}
}
The bug happens in the last save. It appears due to the cloning of a model, the related record ID gets messed up and instead of updating leg2's transfer_payment_id AD actually updates the other record.
If `clone` is replaced with 'new' then no problems appear.
Clone must be made safe.
- [ ] Implement a tes-case for thi scase
- [ ] fix
We need to make sure our code is written well.
@jancha: ther's a hook " $m->hook('initSelectQuery', [$q]);" called pretty much regardless of the action type
Types such as 'string', 'date', 'int' and 'boolean' (or bool) should be standart and all persistences should know how to deal with those types.
Currently we use some terms randomly.
etc. We should clean up our vocabulary and review the software to make sure it's all clean.
Run our unit tests in Travis and test automatically on PRs.
Create a basic documentation outline with Sphinx.
The initial unit tests
Either Dirty or comparing with the original values. Not sure which one yet
Dirty: will fail if same value is written back.
Original: need to store original value and needlessly compare.
Perhaps a combination can be used, e.g. copy-on-modify.
$m['name'] = 'John';
var_dump($m->saveAction());
^^ the query should only update 'name' and not 'surname'
Ability to use addCondition() and reduce accessible DataSet of a model.
I'd like to see the library into the PSR standards, it grants better project acceptation and framework interoperability.
Reference: http://www.php-fig.org
two separate implementations for Array and SQL.
PR #81 went in without doc, need to review "Field" documentation.
We need people who will read documentation, make sure it's properly cross-linked, fix language, make sure examples look consistent and that documentation overall is easy to read.
Out of date documents:
Review clarity:
As framework extend the base Model class, they may want to use their own "Field" class also, which will be more handy for storing some UI-related fields (e.g. hint, caption, etc). As we are not concerned with those, we should make it possible to extend.
On other hand, we do want certain properties to be stored such as type, length, enum.
Zero features implemented, but test our release process.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.