Fixed DBAL-139 Oracle's sequences with NOCACHE #204

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

ghost commented Sep 23, 2012

Added cache size to sequence object.
NOCACHE is set with value 0.

Tested on local machine with test function but there is 5 tests that fails on current master branch on oracle DB 11.2.0.1 so I did not incorporate my test function for this.

I'e used WriteTest and added 3 more sequences with cache 0,1 and 55 and it passed, sequences are created in current schema on oracle db.

@@ -172,7 +172,8 @@ public function getCreateSequenceSQL(Sequence $sequence)
return 'CREATE SEQUENCE ' . $sequence->getQuotedName($this) .
' START WITH ' . $sequence->getInitialValue() .
' MINVALUE ' . $sequence->getInitialValue() .
- ' INCREMENT BY ' . $sequence->getAllocationSize();
+ ' INCREMENT BY ' . $sequence->getAllocationSize().
+ $sequence->getCacheSize();

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 23, 2012

Member

wrond indentation (it should use spaces, not tabs)

@stof

stof Sep 23, 2012

Member

wrond indentation (it should use spaces, not tabs)

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Sep 23, 2012

Are there formatting rules specified, could not found it anywhere, or I should learn from current code?

@ghost

ghost Sep 23, 2012

Are there formatting rules specified, could not found it anywhere, or I should learn from current code?

This comment has been minimized.

Show comment Hide comment

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Sep 23, 2012

Cool, thnx, I'll flow this from now on.

@ghost

ghost Sep 23, 2012

Cool, thnx, I'll flow this from now on.

@@ -74,7 +80,24 @@ public function setInitialValue($initialValue)
{
$this->_initialValue = (is_numeric($initialValue))?$initialValue:1;
}
-
+

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 23, 2012

Member

Please don't ad trailing whitespaces

@stof

stof Sep 23, 2012

Member

Please don't ad trailing whitespaces

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Sep 23, 2012

Maybe the same Q like last one, why not, just want to know for the future commits?

@ghost

ghost Sep 23, 2012

Maybe the same Q like last one, why not, just want to know for the future commits?

+
+ public function getCacheSize()
+ {
+ return $this->_cacheSize;

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 23, 2012

Member

Please use 4 spaces for the indentation, not tabs

@stof

stof Sep 23, 2012

Member

Please use 4 spaces for the indentation, not tabs

+ case 1: $this->_cacheSize = 'CACHE 20';
+ break;
+ default:
+ $this->_cacheSize = 'CACHE '.((is_numeric($cacheSize))?($cacheSize >(ceil(pow(10,27) - $this->_initialValue))/abs($this->_allocationSize)?20:$cacheSize):20);

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 23, 2012

Member

wrong formatting. It should look like this:

switch ($cacheSize) {
    case 0:
        $this->_cacheSize = 'NOCACHE';
        break;
    case 1:
        $this->_cacheSize = 'CACHE 20';
        break;
    default:
        switch (true) {
            case (!(is_numeric($cacheSize)):
                $size = 20;
                break;
            case ($cacheSize > (ceil(pow(10,27) - $this->_initialValue))/abs($this->_allocationSize)):
                $size = 20;
                break;
            default:
                $size = $cacheSize;
        }
        $this->_cacheSize = $this->_cacheSize = 'CACHE '.$size;
}
@stof

stof Sep 23, 2012

Member

wrong formatting. It should look like this:

switch ($cacheSize) {
    case 0:
        $this->_cacheSize = 'NOCACHE';
        break;
    case 1:
        $this->_cacheSize = 'CACHE 20';
        break;
    default:
        switch (true) {
            case (!(is_numeric($cacheSize)):
                $size = 20;
                break;
            case ($cacheSize > (ceil(pow(10,27) - $this->_initialValue))/abs($this->_allocationSize)):
                $size = 20;
                break;
            default:
                $size = $cacheSize;
        }
        $this->_cacheSize = $this->_cacheSize = 'CACHE '.$size;
}

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 23, 2012

Member

a better solution could even be to use a single switch (true) btw.

@stof

stof Sep 23, 2012

Member

a better solution could even be to use a single switch (true) btw.

@stof

This comment has been minimized.

Show comment Hide comment
@stof

stof Sep 23, 2012

Member

and tests are missing

Member

stof commented Sep 23, 2012

and tests are missing

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Sep 23, 2012

Regarding tests, current branch does not pass 5 of them on oracle db.
I could write test for this in next few weeks when Ill have time.

ghost commented Sep 23, 2012

Regarding tests, current branch does not pass 5 of them on oracle db.
I could write test for this in next few weeks when Ill have time.

This comment has been minimized.

Show comment Hide comment
@ghost

ghost Sep 23, 2012

Will apply suggested changes in next weeks.
Please point me to formatting rules specified if there are any written.

ghost commented Sep 23, 2012

Will apply suggested changes in next weeks.
Please point me to formatting rules specified if there are any written.

@beberlei

This comment has been minimized.

Show comment Hide comment
@beberlei

This comment has been minimized.

Show comment Hide comment
@beberlei

beberlei Jan 6, 2013

Owner

@AduroIdea Please add this for PostgreSQL as well, as it supports the exact same syntax, see

http://www.postgresql.org/docs/9.2/static/sql-createsequence.html

Owner

beberlei commented Jan 6, 2013

@AduroIdea Please add this for PostgreSQL as well, as it supports the exact same syntax, see

http://www.postgresql.org/docs/9.2/static/sql-createsequence.html

@beberlei

This comment has been minimized.

Show comment Hide comment
@beberlei

beberlei Dec 22, 2013

Owner

Added in master for Oracle and PostgreSQL.

Owner

beberlei commented Dec 22, 2013

Added in master for Oracle and PostgreSQL.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment