OK, I've uncovered some very strange behaviour.  






























*require 'bcrypt'require 'sequel'DL.create_table? :pwtest_a do  primary_key 
  :id  String :uname, size: 16  String :pw, size: 64  DateTime      :cdate, 
default: Sequel::CURRENT_TIMESTAMPendclass PWtest < 
Sequel::Model(DL[:pwtest_a])end # /class 
PWtest############################################################# 
/setupputs '### Record generation'DL[:pwtest_a].deletea = PWtest.newa.uname 
= RFFaker.usernameputs 
'############################################################# 1'ap apwtemp 
= Gen.pw(24)puts "1 a.pw: #{ a.pw }"puts pwtemp#   pwtemp = 
'wqhscuzladPmtxonygrvMiEj'puts "2 a.pw: #{ a.pw }"a.pw = pwtemp # this 
seems to be the problemputs "3 a.pw: #{ a.pw }"puts 
'############################################################# 2'ap 
a10.times { puts a.pw } # Why does this value change on every iteration?*

Hopefully that will run for you.  For some reason that property is changing 
without me changing anything in that object.  Am I missing something 
besides sleep?

Cheers
On Sunday, September 24, 2023 at 10:49:49 PM UTC-4 Jeremy Evans wrote:

> On Sun, Sep 24, 2023 at 5:45 PM [email protected] <[email protected]> wrote:
>
>> For soem reason I have a field that's changing upon assigning it as a 
>> property value.  I have no clue why.  
>>
>>
>>
>>
>>
>>
>>
>> *DL.create_table? :pwtest do  primary_key   :id  String :uname, size: 16  
>> String :pw, size: 64  DateTime      :cdate, default: 
>> Sequel::CURRENT_TIMESTAMPend*
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *class PWtest < Sequel::Model(DL[:pwtest])  def save_new()    pwpresave = 
>> BCrypt::Password.create(self.pw <http://self.pw>)    puts '### save_new'    
>> puts pwpresave.version, pwpresave.cost    puts pwpresave == "#{ self.pw 
>> <http://self.pw> }"    puts '/save_new'      DL[:pwtest].insert(uname: 
>> self.uname, pw: pwpresave)  endend*
>>
>>
>> Performance script:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *DL[:pwtest].deletehold = []puts '### Records generation'1.times do  a = 
>> PWtest.new  a.uname = RFFaker.username  pwtemp = Gen.pw(24)  a.pw 
>> <http://a.pw> = pwtemp  Dev.feedback("pwtemp", pwtemp) if true  
>> Dev.feedback("a.pw <http://a.pw>", a.pw <http://a.pw>) if true  
>> Dev.feedback("Digest MD5", Digest::MD5.hexdigest(pwtemp)) if true  
>> Dev.feedback("a.pw <http://a.pw> == pwtemp", a.pw <http://a.pw> == pwtemp) 
>> if true  a.save_new  ap aend*
>> Here is the output:
>>
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> *### Records generation /users/rich/app.rb (286)          pwtemp: 
>> cMkxfdnvjyhowqiEKpaPermg /users/rich/app.rb (287)            a.pw 
>> <http://a.pw>: hWvfMpey /users/rich/app.rb (288)      Digest MD5: 
>> c4bac7b0d1014c353b8e8405c7fb7021 /users/rich/app.rb (289)  a.pw 
>> <http://a.pw> == pwtemp: falsesave_new2a12false/save_new*
>>
>>
>>
>> *{    :uname => "deandre738",       :pw => "cMkxfdnvjyhowqiEKpaPermg"}*
>>
>>
>> __pwtemp__ shows proper.  __a.pw__ was assigned __pwtemp__ but or some 
>> reason comes up short.  I can only guess that `PostgreSQL` is doing this, 
>> as my code is not.  But that fieldname of `pw` shouldn't introduce any 
>> automatic encryption, nor is that turned on anyway.  So I'm confused as to 
>> why this is happening.  
>>
>> I know the answer is right in front of my face.  What am I doing wrong?
>>
>
> Not sure.  Your script wasn't self-contained, and I cannot replicate the 
> problem.  Here's a mostly self-contained script I ran with bin/sequel (it 
> is not completely self-contained, as it requires bcrypt):
>
> require 'bcrypt'
>
> DB.create_table? :pwtest do
>
>   primary_key   :id
>   String :uname, size: 16
>   String :pw, size: 64
>   DateTime      :cdate, default: Sequel::CURRENT_TIMESTAMP
> end
>
> class PWtest < Sequel::Model(DB[:pwtest])
>
>   def save_new()
>     pwpresave = BCrypt::Password.create(self.pw)
>     puts '### save_new'
>     puts pwpresave.version, pwpresave.cost
>     puts pwpresave == "#{ self.pw }"
>     puts '/save_new'
>  
>     DB[:pwtest].insert(uname: self.uname, pw: pwpresave)
>   end
> end
>
>
> DB[:pwtest].delete
>
> hold = []
> puts '### Records generation'
> 1.times do
>   a = PWtest.new
>   a.uname = 'deandre738'
>   pwtemp = 'cMkxfdnvjyhowqiEKpaPermg'
>   a.pw = pwtemp
>   p(a.pw == pwtemp)
>   a.save_new
>   p a
> end
>
> Output:
>
> $ ruby bin/sequel sqlite:/ t.rb
> ### Records generation
> true
> ### save_new
> 2a
> 12
> true
> /save_new
> #<PWtest @values={:uname=>"deandre738", :pw=>"cMkxfdnvjyhowqiEKpaPermg"}>
>
> Since this prints true before "### save new" and true before "/save_new", 
> I'm guessing it doesn't have the issue you were experiencing.  Hopefully it 
> helps you debug the problem.
>
> Thanks,
> Jeremy 
>

-- 
You received this message because you are subscribed to the Google Groups 
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sequel-talk/b74d6409-d920-4a53-9396-35d6fe972d9bn%40googlegroups.com.

Reply via email to