Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove reference to undeclared variable TypeConverters. #20

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions MySQL-Core/ByteArray.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Extension { #name : 'ByteArray' }

{ #category : '*MySQL-Core' }
ByteArray >> mySQLParamTypeFor: aMySQLBindParameter [

self size < 16r100 ifTrue: [^MySQLTypes typeTINYBLOB].
self size < 16r10000 ifTrue: [^MySQLTypes typeBLOB].
self size < 16r1000000 ifTrue: [^MySQLTypes typeMEDIUMBLOB].

^MySQLTypes typeLONGBLOB
]
7 changes: 7 additions & 0 deletions MySQL-Core/Character.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : 'Character' }

{ #category : '*MySQL-Core' }
Character >> mySQLParamTypeFor: aMySQLBindParameter [

^MySQLTypes typeSTRING
]
7 changes: 7 additions & 0 deletions MySQL-Core/Date.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Extension { #name : 'Date' }

{ #category : '*MySQL-Core' }
Date >> mySQLParamTypeFor: aMySQLBindParameter [

^MySQLTypes typeDATE
]
10 changes: 8 additions & 2 deletions MySQL-Core/DateAndTime.extension.st
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Extension { #name : #DateAndTime }
Extension { #name : 'DateAndTime' }

{ #category : #'*MySQL-Core' }
{ #category : '*MySQL-Core' }
DateAndTime >> asISOString [
^ String streamContents: [ :aStream |
self printYMDOn: aStream.
Expand All @@ -11,3 +11,9 @@ DateAndTime >> asISOString [
aStream nextPut: $:.
self seconds printOn: aStream base: 10 length: 2 padded: true]
]

{ #category : '*MySQL-Core' }
DateAndTime >> mySQLParamTypeFor: aMySQLBindParameter [

^MySQLTypes typeDATETIME
]
13 changes: 13 additions & 0 deletions MySQL-Core/Duration.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Extension { #name : 'Duration' }

{ #category : '*MySQL-Core' }
Duration >> mySQLParamSign [

^self positive
]

{ #category : '*MySQL-Core' }
Duration >> mySQLParamTypeFor: aMySQLBindParameter [

^MySQLTypes typeTIME
]
18 changes: 18 additions & 0 deletions MySQL-Core/Integer.extension.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Extension { #name : 'Integer' }

{ #category : '*MySQL-Core' }
Integer >> digitAt: index [

^self at: index
]

{ #category : '*MySQL-Core' }
Integer >> mySQLParamTypeFor: aMySQLBindParameter [

(aMySQLBindParameter isInTinyIntRange: self) ifTrue: [^ MySQLTypes typeTINY].
(aMySQLBindParameter isInSmallIntRange: self) ifTrue: [^ MySQLTypes typeSHORT].
(aMySQLBindParameter isInLongIntRange: self) ifTrue: [^ MySQLTypes typeLONG].
(aMySQLBindParameter isInBigIntRange: self) ifTrue: [^ MySQLTypes typeLONGLONG].

MySQLBindError signal: 'Supplied integer does not have a matching database type'
]
14 changes: 8 additions & 6 deletions MySQL-Core/MySQL323Scramble.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@
323 scramble packet for MySQL
"
Class {
#name : #MySQL323Scramble,
#superclass : #MySQLPacket,
#name : 'MySQL323Scramble',
#superclass : 'MySQLPacket',
#instVars : [
'scrambleBuff',
'password'
],
#category : #'MySQL-Core-Packet'
#category : 'MySQL-Core-Packet',
#package : 'MySQL-Core',
#tag : 'Packet'
}

{ #category : #accessing }
{ #category : 'accessing' }
MySQL323Scramble >> password: pwd [
password := pwd

]

{ #category : #accessing }
{ #category : 'accessing' }
MySQL323Scramble >> scrambleBuff: scramble [
scrambleBuff := scramble

]

{ #category : #writing }
{ #category : 'writing' }
MySQL323Scramble >> write [
| scrmbl buffStream |
buffStream := WriteStream on: (ByteArray new: 256).
Expand Down
50 changes: 26 additions & 24 deletions MySQL-Core/MySQLBinaryReader.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@
Binary reader for MySQL
"
Class {
#name : #MySQLBinaryReader,
#superclass : #Object,
#name : 'MySQLBinaryReader',
#superclass : 'Object',
#classInstVars : [
'defaultInstance'
],
#category : #'MySQL-Core-Utilities'
#category : 'MySQL-Core-Utilities',
#package : 'MySQL-Core',
#tag : 'Utilities'
}

{ #category : #'as yet unclassified' }
{ #category : 'as yet unclassified' }
MySQLBinaryReader class >> default [
defaultInstance isNil ifTrue: [ defaultInstance := self new ].
^ defaultInstance
]

{ #category : #integer }
{ #category : 'integer' }
MySQLBinaryReader >> bigIntFrom: aStream [
^ aStream next + (aStream next << 8) + (aStream next << 16) + (aStream next << 24) +
(aStream next << 32) + (aStream next << 40) + (aStream next << 48) + (aStream next << 56)

]

{ #category : #time }
{ #category : 'time' }
MySQLBinaryReader >> dateFrom: aStream [ "ByteStream"
"Ref: libmysql.c >> read_binary_date"
| len year month day |
Expand All @@ -41,7 +43,7 @@ MySQLBinaryReader >> dateFrom: aStream [ "ByteStream"

]

{ #category : #time }
{ #category : 'time' }
MySQLBinaryReader >> dateTimeFrom: aStream [ "ByteStream"
"Ref: libmysql.c >> read_binary_datetime"
"length(1) + year(2) + month(1) + day(1) + hh(1) + mm(1) + ss(1) + micoSeconds(4)"
Expand All @@ -51,32 +53,32 @@ MySQLBinaryReader >> dateTimeFrom: aStream [ "ByteStream"
length = 0 ifTrue: [^ nil].

year := self smallIntFrom: aStream.
month := self tinyIntFrom: aStream..
day := self tinyIntFrom: aStream..
month := self tinyIntFrom: aStream.
day := self tinyIntFrom: aStream.

hh := mm:= ss := ns := 0.
length > 4 ifTrue: [
hh := self tinyIntFrom: aStream..
hh := self tinyIntFrom: aStream.
mm := self tinyIntFrom: aStream.
ss := self tinyIntFrom: aStream.].
ss := self tinyIntFrom: aStream].
length > 7 ifTrue: [ns := (self longIntFrom: aStream) * 1000].

^ DateAndTime
year: year month: month day: day
hour: hh minute: mm second: ss
nanoSecond: ns offset: 0 hours
nanoSecond: ns offset: DateAndTime localOffset

]

{ #category : #real }
{ #category : 'real' }
MySQLBinaryReader >> decimalWithScale: scale from: aStream [
| valueString |
valueString := (MySQLHelper decodeLcsFrom: aStream) asString, 's', scale asString.
^ valueString asNumber

]

{ #category : #real }
{ #category : 'real' }
MySQLBinaryReader >> doubleFrom: aStream [
| num |
num := Float new: 2.
Expand All @@ -87,33 +89,33 @@ MySQLBinaryReader >> doubleFrom: aStream [

]

{ #category : #real }
{ #category : 'real' }
MySQLBinaryReader >> floatFrom: aStream [
^ Float fromIEEE32Bit: (self longIntFrom: aStream)

]

{ #category : #integer }
{ #category : 'integer' }
MySQLBinaryReader >> longIntFrom: aStream [
^ aStream next + (aStream next << 8) + (aStream next << 16) + (aStream next << 24)

]

{ #category : #integer }
{ #category : 'integer' }
MySQLBinaryReader >> mediumIntFrom: aStream [
"int24 is sent as 4 bytes int"
"Ref: libmysql.c >> fetch_result_with_conversion()"
^ self longIntFrom: aStream

]

{ #category : #integer }
{ #category : 'integer' }
MySQLBinaryReader >> smallIntFrom: aStream [
^ aStream next + (aStream next << 8)

]

{ #category : #time }
{ #category : 'time' }
MySQLBinaryReader >> timeFrom: aStream [
"ByteStream"
"length(1) + sign(1) + days(4) + hh(1) + mm(1) + ss(1) + subSeconds(4)"
Expand Down Expand Up @@ -148,33 +150,33 @@ MySQLBinaryReader >> timeFrom: aStream [
ifFalse: [ ^ timeOfDay ]
]

{ #category : #time }
{ #category : 'time' }
MySQLBinaryReader >> timeStampFrom: aStream [ "ByteStream"
^ self dateTimeFrom: aStream.

]

{ #category : #integer }
{ #category : 'integer' }
MySQLBinaryReader >> tinyIntFrom: aStream [
^ aStream next

]

{ #category : #blob }
{ #category : 'blob' }
MySQLBinaryReader >> varBlobFrom: aStream [
^ MySQLHelper decodeLcsFrom: aStream


]

{ #category : #string }
{ #category : 'string' }
MySQLBinaryReader >> varStringFrom: aStream [
^ (self varBlobFrom: aStream) asString


]

{ #category : #time }
{ #category : 'time' }
MySQLBinaryReader >> yearFrom: aStream [ "ByteStream"
^ self smallIntFrom: aStream

Expand Down
24 changes: 13 additions & 11 deletions MySQL-Core/MySQLBinaryRowData.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,37 @@
Common superclass for MySQL binary row data
"
Class {
#name : #MySQLBinaryRowData,
#superclass : #MySQLRowData,
#name : 'MySQLBinaryRowData',
#superclass : 'MySQLRowData',
#instVars : [
'header',
'nullBitMap',
'columnDescriptors',
'columnValues'
],
#category : #'MySQL-Core-Packet-RowData'
#category : 'MySQL-Core-Packet-RowData',
#package : 'MySQL-Core',
#tag : 'Packet-RowData'
}

{ #category : #accessing }
{ #category : 'accessing' }
MySQLBinaryRowData >> atIndex: indx [
^ columnValues at: indx ifAbsent: [MySQLInvalidRowAccess signal: 'No data at this index']

]

{ #category : #accessing }
{ #category : 'accessing' }
MySQLBinaryRowData >> columnDescriptors: fieldList [
columnDescriptors := fieldList

]

{ #category : #enumerating }
{ #category : 'enumerating' }
MySQLBinaryRowData >> do: aBlock [
^columnValues do: aBlock
]

{ #category : #testing }
{ #category : 'testing' }
MySQLBinaryRowData >> isColumnNullAt: index [
| byteIndex bitsToShift bitMask |
byteIndex := index + 9 // 8.
Expand All @@ -42,18 +44,18 @@ MySQLBinaryRowData >> isColumnNullAt: index [

]

{ #category : #accessing }
{ #category : 'accessing' }
MySQLBinaryRowData >> last [
^ self atIndex: (columnValues size)
]

{ #category : #accessing }
{ #category : 'accessing' }
MySQLBinaryRowData >> nullBitMap: byteArray [ "primarily for testing"
nullBitMap := byteArray

]

{ #category : #parsing }
{ #category : 'parsing' }
MySQLBinaryRowData >> parse [
| col |
header := inStream next. "always 0"
Expand All @@ -72,7 +74,7 @@ MySQLBinaryRowData >> parse [
put: col ]
]

{ #category : #reading }
{ #category : 'reading' }
MySQLBinaryRowData >> readColumnFrom: aStream perDescrption: columnDescr [
| reader value mask |

Expand Down
8 changes: 5 additions & 3 deletions MySQL-Core/MySQLBindError.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@
Binding error for MySQL
"
Class {
#name : #MySQLBindError,
#superclass : #MySQLDriverError,
#category : #'MySQL-Core-Exception'
#name : 'MySQLBindError',
#superclass : 'MySQLDriverError',
#category : 'MySQL-Core-Exception',
#package : 'MySQL-Core',
#tag : 'Exception'
}
Loading
Loading