Git Product home page Git Product logo

sagan's People

Contributors

fortizpenaloza avatar gcotelli avatar hurrellt avatar jvanecek avatar mtabacman avatar tamyer avatar ytsejam78 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sagan's Issues

Reintroduce support for MySQL

In the PR
#60
the support for MySQL was discontinued since it was not being actively maintained, and relied at least partially on old dependencies.
This issue is to remember that should eventually add back support, with up to date dependencies and drivers.

Update problem with session pool

If update:with: is performed in a different session from the one used to read the original object, it fails as Glorp tries to do an insert instead of an update.

Problem is already documented in this test:
PooledRDBMSRepositoryProviderTest>>testUpdateWithOutsideTransactWillFail

Workaround for now is to re-read the object before updating it, within the same transaction to ensure same session is used.
For example, update method for a trade registration system:

updateTrade: originalTrade with: updatedTrade

	^trades transact: [:session |
		trades
			withOneMatching: [:trade :builder | builder does: trade equal: originalTrade]
			do: [:trade | trades update: trade with: updatedTrade]
			else: [ObjectNotFound signal: ('<1p> was not found.' expandMacrosWith: originalTrade)]]

Method update:with: should always return the updated object

RDBMSRepository>>update: aMutableDomainObject executing: aMonadycBlock

	self
		transact: [ :session | 
			| originalObject |

			originalObject := session refresh: aMutableDomainObject.
			session modify: originalObject in: [ aMonadycBlock value: originalObject ]
			].
	^ aMutableDomainObject

As seen above this method currently returns the aMutableDomainObject.
This is fine as long as we use a single session to the database within the same Smalltalk image.
It does not work well when using a session pool because the synchronizeWith: is sent to the original object after doing a refresh (not the same instance).
The method should return the result of the modify, which is the object returned in the method modify:in:

Update with relationship mappings

By default, Glorp is using proxies for all attributes in relationship mappings.
See method: RelationshipMapping>>initialize.

This is fine and we would normally leave this enabled and resolve the proxy during postFetch.
However, using a pooled session repository provider this is not possible unless objects are somehow shared between sessions or by other means (not sure how).

I am documenting this with more unit tests and will soon submit the changes. I will also add more information to this issue.

Workaround for now, without disabling a session pool, is use relationship mappings for attributes with use of proxies disabled.

Support common use of NULL field querying

It is common for an application to represent certain objects with a null value in a database field.
For example, when you use the null object pattern, it is straightfoward to think of a nullable field in the database table representing the null object with a NULL value and the non-null object with the field value, which could be a string, a number, a timestamp, etc.
One could then expect Sagan to provide a way of building the SQL command to query the database for registers where certain field is NULL or satisfies any other expression (most common use is with OR).
So, it would be nice for the matching criteria builder to add support for this.
And, it would be extra nice if mapping definitions provide a way of creating these kind of mappings in a simple way.

Different repository implementations?

This was briefly discussed between Gabriel and I. Other opinions are welcome.
If we model the storing, purging, updating and finding, it seems the repository could be implemented with a single class (goodbye hierarchy).

Two main points make me think this:

  1. Currently the superclass defines subclass responsibilities which do not make sense for all subclasses (e.g. #configureMappingsIn:)
  2. It defines common behavior which could be extracted to other objects which are easy to create (as I said, the actions for store, purge, update and access the repository elements)

I think this idea is worth trying and not too difficult to try in this early stage of development.
For example, the store action which is the same for all implementations, would be another object which when evaluated, it would perform the assertion for conflict check (which will be a collaboration with the conflict checking strategy which is already a different object) and then store the object.

It feels we could achieve same behavior with one less hierarchy and creating more reusable objects.
Not sure if transaction management gets in the way for all implementations other than InMemory variant, but I am sure it could be solved with more object composition.

Tests don't drop tables and conflicts sometimes when different suites uses same tables

Say one test uses 2 tables (X with a fk to Y).
If you run a second test that uses Y, glorp will try to recreate it (drop it and create it again), but as the constrain of the fk in table X still exists in the db, the drop fails.
One solution is that the tearDown of the tests explicitly drop the tables, so the repositories needs to have a protocol to do it.

More than one repository not working

When using more than one repository, during #configureMappingsIn: the first repository setups the session causing the descriptor system to perform a validation (see method: GlorpSession>>system:).
Due to how Sagan's configurable descriptor system works, this causes only the first repository's tables, class descriptors and mappings to be created. The rest only exist as definitions which are never evaluated because of lazy variable initializations.

Pharo 6.1 support

Currently the only thing not working in Pharo 6.1 are the sorting features, because the SortFunction hierarchy is different to the one in Pharo 7.

Maybe it makes sense to have a package loadable in Pharo 6.1 with the required extensions. The other tests are already working on Pharo 6.1

Drop support for 32 bits version

Remove from the build matrix the support for 32 bits versions of Pharo.
It makes the build take twice the time for not too much gain. We can't support old tech forever.

Allow to configure session pool

Expose some parameters so the users can configure the session pool:

  • maxIdleObjects (defaulting to 10)
  • minIdleObjects (defaulting to 5)
  • maxActiveObjects (defaulting to 12)

Support for MySQL 8

This requires changes in the underlying support:
Failed to connect to server: Client does not support authentication protocol requested by server; consider upgrading MySQL client

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.