<commit_before>//
//  DBModel.swift
//  ActiveSQLite
//
//  Created by <NAME> on 05/06/2017.
//  Copyright © 2017 <EMAIL>. All rights reserved.
//

import Foundation
import SQLite

protocol ASModel:class {
    
}
/*
 Model Type    SQLite.swift Type      SQLite Type
 NSNumber    Int64(Int,Bool)         INTEGER
 NSNumber    Double                  REAL
 String      String                  TEXT
 nil         nil                     NULL
 SQLite.Blob†	        BLOB //not used
 NSDate      Int64                   INTEGER
 */

open class DBModel: NSObject,ASModel{
    
    public var id:NSNumber! //id primary key
    public var created_at:NSNumber! //Create Time, ms
    public var updated_at:NSNumber! // Update Time，ms
    
    
    static var id = Expression<NSNumber>("id")
    static let created_at = Expression<NSNumber>("created_at")
    static let updated_at = Expression<NSNumber>("updated_at")
    
    var created_date:NSDate! {
        set{
            created_at = NSNumber(value:newValue.timeIntervalSince1970 * 1000)
        }
        get{
            return NSDate(timeIntervalSince1970: TimeInterval(created_at.int64Value/1000))
        }
    }
    var updated_date:NSDate! {
        set{
            updated_at = NSNumber(value:newValue.timeIntervalSince1970 * 1000)
        }
        get{
            return NSDate(timeIntervalSince1970: TimeInterval(updated_at.int64Value/1000))
        }
    }
    
    
    //T? == Optional<T>
    //T! == ImplicitlyUnwrappedOptional<T>
    static var db:Connection!{
        get{
            return DBConnection.sharedConnection.db
        }
    }
    var _query:QueryType?
    
    required override public init() {
        super.init()
    }
    
    func doubleTypes() -> [String]{
        return [String]()
    }
    
    open class func mapper() -> [String:String]{
        return [String:String]()
    }
    
    open class func transientTypes() -> [String]{
        return [String]()
    }
    
    
    func recursionPropertiesOnlyColumn() -> [(String?,Any)]{
        
        var properties = [(String?,Any)]()
        var mirror: Mirror? = Mirror(reflecting: self)
        repeat {
            for case let (key?, value) in mirror!.children {
                
                let mir = Mirror(reflecting:value)
                
                switch mir.subjectType {
                    
                case _ as String.Type, _ as  ImplicitlyUnwrappedOptional<String>.Type,_ as String?.Type,_ as NSNumber.Type, _ as  ImplicitlyUnwrappedOptional<NSNumber>.Type,_ as NSNumber?.Type,
                     _ as NSDate.Type, _ as ImplicitlyUnwrappedOptional<NSDate>.Type,_ as NSDate?.Type:
                    
                    if let column = (type(of:self)).mapper()[key] {
                        properties.append((column, value))
                    }else{
                        properties.append((key, value))
                    }
                    
                    
                    break
                    
                default: break
                    
                }
                
            }
            mirror = mirror?.superclassMirror
        } while mirror != nil
        
        
        return properties.sorted(by: {
            if $0.0 == "id" {
                return true
            }
            return $0.0! < $1.0!
        } )
    }
    
    func recursionProperties() -> [(String?,String?,Any)]{
        
        var properties = [(String?,String?,Any)]()
        var mirror: Mirror? = Mirror(reflecting: self)
        repeat {
            for case let (key?, value) in mirror!.children {
                
                if (type(of:self)).transientTypes().contains(key)  {
                    continue
                }
                
                let mir = Mirror(reflecting:value)
                
                switch mir.subjectType {
                    
                case _ as String.Type, _ as  ImplicitlyUnwrappedOptional<String>.Type,_ as String?.Type,_ as NSNumber.Type, _ as  ImplicitlyUnwrappedOptional<NSNumber>.Type,_ as NSNumber?.Type,
                     _ as NSDate.Type, _ as ImplicitlyUnwrappedOptional<NSDate>.Type,_ as NSDate?.Type:
                    
                    if let column = (type(of:self)).mapper()[key] {
                        properties.append((key, column, value))
                    }else{
                        properties.append((key, key, value))
                    }
                    
                    
                    break
                    
                default: break
                    
                }
                
            }
            mirror = mirror?.superclassMirror
        } while mirror != nil
        
        
        return properties.sorted(by: {
            if $0.0 == "id" {
                return true
            }
            return $0.0! < $1.0!
        } )
    }
    
    func propertieColumnMap() -> [String:String]{
        
        var pcMap = [String:String]()
        var mirror: Mirror? = Mirror(reflecting: self)
        repeat {
            for case let (key?, value) in mirror!.children {
                
                if (type(of:self)).transientTypes().contains(key)  {
                    continue
                }
                
                let mir = Mirror(reflecting:value)
                
                switch mir.subjectType {
                    
                case _ as String.Type, _ as  ImplicitlyUnwrappedOptional<String>.Type,_ as String?.Type,_ as NSNumber.Type, _ as  ImplicitlyUnwrappedOptional<NSNumber>.Type,_ as NSNumber?.Type,
                     _ as NSDate.Type, _ as ImplicitlyUnwrappedOptional<NSDate>.Type,_ as NSDate?.Type:
                    
                    if let column = (type(of:self)).mapper()[key] {
                        pcMap[key] = column
                    }else{
                        pcMap[key] = key
                    }
                    
                    
                    break
                    
                default: break
                    
                }
                
            }
            mirror = mirror?.superclassMirror
        } while mirror != nil
        
        
        return pcMap
    }
    
    
    override open var description: String{
        var des = "**DB Model**：" + super.description + "->"
        //        var des = "**DB Model**" + NSStringFromClass(type(of:self)) + "-> "
        
        for case let (attribute?, column?, value) in recursionProperties(){
            //            if attribute == "created_at" || attribute == "updated_at" {
            //                des += "\(attribute) = \((value as! NSNumber).int64Value), "
            //            }else{
            des += "\(attribute) = \(value), "
            //            }
            
        }
        return des
    }
    
}



<commit_msg>modified access levels of DBModel<commit_after>//
//  DBModel.swift
//  ActiveSQLite
//
//  Created by <NAME> on 05/06/2017.
//  Copyright © 2017 <EMAIL>. All rights reserved.
//

import Foundation
import SQLite

protocol ASModel:class {
    
}
/*
 Model Type    SQLite.swift Type      SQLite Type
 NSNumber    Int64(Int,Bool)         INTEGER
 NSNumber    Double                  REAL
 String      String                  TEXT
 nil         nil                     NULL
 SQLite.Blob†	        BLOB //not used
 NSDate      Int64                   INTEGER
 */

open class DBModel: NSObject,ASModel{
    
    public var id:NSNumber! //id primary key
    public var created_at:NSNumber! //Create Time, ms
    public var updated_at:NSNumber! // Update Time，ms
    
    
    public static var id = Expression<NSNumber>("id")
    public static let created_at = Expression<NSNumber>("created_at")
    public static let updated_at = Expression<NSNumber>("updated_at")
    
    public var created_date:NSDate! {
        set{
            created_at = NSNumber(value:newValue.timeIntervalSince1970 * 1000)
        }
        get{
            return NSDate(timeIntervalSince1970: TimeInterval(created_at.int64Value/1000))
        }
    }
    public var updated_date:NSDate! {
        set{
            updated_at = NSNumber(value:newValue.timeIntervalSince1970 * 1000)
        }
        get{
            return NSDate(timeIntervalSince1970: TimeInterval(updated_at.int64Value/1000))
        }
    }
    
    
    //T? == Optional<T>
    //T! == ImplicitlyUnwrappedOptional<T>
    static var db:Connection!{
        get{
            return DBConnection.sharedConnection.db
        }
    }
    var _query:QueryType?
    
    required override public init() {
        super.init()
    }
    
    func doubleTypes() -> [String]{
        return [String]()
    }
    
    open class func mapper() -> [String:String]{
        return [String:String]()
    }
    
    open class func transientTypes() -> [String]{
        return [String]()
    }
    
    
    func recursionPropertiesOnlyColumn() -> [(String?,Any)]{
        
        var properties = [(String?,Any)]()
        var mirror: Mirror? = Mirror(reflecting: self)
        repeat {
            for case let (key?, value) in mirror!.children {
                
                let mir = Mirror(reflecting:value)
                
                switch mir.subjectType {
                    
                case _ as String.Type, _ as  ImplicitlyUnwrappedOptional<String>.Type,_ as String?.Type,_ as NSNumber.Type, _ as  ImplicitlyUnwrappedOptional<NSNumber>.Type,_ as NSNumber?.Type,
                     _ as NSDate.Type, _ as ImplicitlyUnwrappedOptional<NSDate>.Type,_ as NSDate?.Type:
                    
                    if let column = (type(of:self)).mapper()[key] {
                        properties.append((column, value))
                    }else{
                        properties.append((key, value))
                    }
                    
                    
                    break
                    
                default: break
                    
                }
                
            }
            mirror = mirror?.superclassMirror
        } while mirror != nil
        
        
        return properties.sorted(by: {
            if $0.0 == "id" {
                return true
            }
            return $0.0! < $1.0!
        } )
    }
    
    func recursionProperties() -> [(String?,String?,Any)]{
        
        var properties = [(String?,String?,Any)]()
        var mirror: Mirror? = Mirror(reflecting: self)
        repeat {
            for case let (key?, value) in mirror!.children {
                
                if (type(of:self)).transientTypes().contains(key)  {
                    continue
                }
                
                let mir = Mirror(reflecting:value)
                
                switch mir.subjectType {
                    
                case _ as String.Type, _ as  ImplicitlyUnwrappedOptional<String>.Type,_ as String?.Type,_ as NSNumber.Type, _ as  ImplicitlyUnwrappedOptional<NSNumber>.Type,_ as NSNumber?.Type,
                     _ as NSDate.Type, _ as ImplicitlyUnwrappedOptional<NSDate>.Type,_ as NSDate?.Type:
                    
                    if let column = (type(of:self)).mapper()[key] {
                        properties.append((key, column, value))
                    }else{
                        properties.append((key, key, value))
                    }
                    
                    
                    break
                    
                default: break
                    
                }
                
            }
            mirror = mirror?.superclassMirror
        } while mirror != nil
        
        
        return properties.sorted(by: {
            if $0.0 == "id" {
                return true
            }
            return $0.0! < $1.0!
        } )
    }
    
    func propertieColumnMap() -> [String:String]{
        
        var pcMap = [String:String]()
        var mirror: Mirror? = Mirror(reflecting: self)
        repeat {
            for case let (key?, value) in mirror!.children {
                
                if (type(of:self)).transientTypes().contains(key)  {
                    continue
                }
                
                let mir = Mirror(reflecting:value)
                
                switch mir.subjectType {
                    
                case _ as String.Type, _ as  ImplicitlyUnwrappedOptional<String>.Type,_ as String?.Type,_ as NSNumber.Type, _ as  ImplicitlyUnwrappedOptional<NSNumber>.Type,_ as NSNumber?.Type,
                     _ as NSDate.Type, _ as ImplicitlyUnwrappedOptional<NSDate>.Type,_ as NSDate?.Type:
                    
                    if let column = (type(of:self)).mapper()[key] {
                        pcMap[key] = column
                    }else{
                        pcMap[key] = key
                    }
                    
                    
                    break
                    
                default: break
                    
                }
                
            }
            mirror = mirror?.superclassMirror
        } while mirror != nil
        
        
        return pcMap
    }
    
    
    override open var description: String{
        var des = "**DB Model**：" + super.description + "->"
        //        var des = "**DB Model**" + NSStringFromClass(type(of:self)) + "-> "
        
        for case let (attribute?, column?, value) in recursionProperties(){
            //            if attribute == "created_at" || attribute == "updated_at" {
            //                des += "\(attribute) = \((value as! NSNumber).int64Value), "
            //            }else{
            des += "\(attribute) = \(value), "
            //            }
            
        }
        return des
    }
    
}




{'fraction_non_alphanumeric': 0.09621645084279823, 'fraction_numerical': 0.009549301888157419, 'mean_word_length': 1.1901140684410647, 'pattern_counts': {'":': 0, '<': 39, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5375677', 'n_tokens_mistral': 3723, 'n_tokens_neox': 3483, 'n_words': 777}